91 lines
3.1 KiB
C++
91 lines
3.1 KiB
C++
|
#include <scene/simplescene.h>
|
||
|
|
||
|
#include <camera/perspectivecamera.h>
|
||
|
#include <shader/materialshader.h>
|
||
|
#include <primitive/sphere.h>
|
||
|
#include <light/ambientlight.h>
|
||
|
#include <light/pointlight.h>
|
||
|
#include <renderer/depthoffieldrenderer.h>
|
||
|
#include <post_processing/bloom.h>
|
||
|
#include <primitive/objmodel.h>
|
||
|
#include <shader/lambertshader.h>
|
||
|
#include <renderer/simplerenderer.h>
|
||
|
#include <shader/brdfshader.h>
|
||
|
#include <thread>
|
||
|
//#include <conio.h>
|
||
|
#include <shader/cooktorranceshader.h>
|
||
|
#include <shader/phongshader.h>
|
||
|
#include <primitive/infiniteplane.h>
|
||
|
#include <light/spotlight.h>
|
||
|
#include <shader/cloudshader.h>
|
||
|
#include <shader/mirrorshader.h>
|
||
|
#include <shader/refractionshader.h>
|
||
|
#include <primitive/triangle.h>
|
||
|
#include <shader/simpleshadowshader.h>
|
||
|
#include <light/sunlight.h>
|
||
|
#include "scene/fastscene.h"
|
||
|
#include "shader/toneshader.h"
|
||
|
#include "renderer/superrenderer.h"
|
||
|
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
FastScene scene;
|
||
|
scene.setEnvironmentMap(std::make_shared<Texture>("data/clear_blue_sky.jpg"));
|
||
|
|
||
|
// Light
|
||
|
// Alternative directio Vector3d(0, -.5f, -.5f)
|
||
|
auto mainLight = std::make_shared<SunLight>(Vector3d(0, -0.09f, 1), 2.0f, Color(1, 1, 1));
|
||
|
scene.add(mainLight);
|
||
|
|
||
|
// Set up the camera
|
||
|
PerspectiveCamera camera;
|
||
|
camera.setFovAngle(100.0f);
|
||
|
camera.setPosition(Vector3d(0, .5f, .5f) * 2);
|
||
|
camera.setForwardDirection(Vector3d(0, .5f, .5f));
|
||
|
camera.setUpDirection(Vector3d(0, .5f, -.5f));
|
||
|
|
||
|
// Shader
|
||
|
Vector3d planePosition = Vector3d(0, 3, 4);
|
||
|
auto plane = std::make_shared<ObjModel>(
|
||
|
std::make_shared<ToneShader>(mainLight, Color(1, 1, 1), Color(1, 0.5f, 0.5f), Color(1, 0.5f, 0.5f) * 0.5f));
|
||
|
plane->loadObj("data/FancyPlane/Plane.obj", Vector3d(1.0f, 1.0f, 1.0f) * 0.005f, planePosition);
|
||
|
scene.add(plane);
|
||
|
|
||
|
// Add clouds
|
||
|
auto cloudSettings = CloudSettings();
|
||
|
cloudSettings.seed = 10;
|
||
|
cloudSettings.scale = 40;
|
||
|
cloudSettings.noiseSize = 512;
|
||
|
cloudSettings.lightAbsorptionTowardsLight = 0.05f;
|
||
|
cloudSettings.lightAbsorptionThroughCloud = 1.9f;
|
||
|
cloudSettings.densityOffset = -0.61f;
|
||
|
auto cloudShader = std::make_shared<CloudShader>(cloudSettings);
|
||
|
scene.add(std::make_shared<Box>(Vector3d(0.0f, 15.0f, 30.0f), Vector3d(100.0f, 15.0f, 70.0f), cloudShader));
|
||
|
|
||
|
scene.buildTree();
|
||
|
|
||
|
// Render
|
||
|
// SuperRenderer rendererTest;
|
||
|
// rendererTest.setSuperSamplingFactor(1);
|
||
|
// int width = 512;
|
||
|
// Texture image = rendererTest.renderImage(scene, camera, width, width / 16 * 9);
|
||
|
|
||
|
// initialize renderer: aperture = lens thickness, secondaryRayCount = how many rays per pixel are created
|
||
|
float focalLength = length(camera.getPosition() - planePosition + Vector3d(0, 0, 2.6f));
|
||
|
DOFRenderer renderer(0.02, 100, focalLength);
|
||
|
float imageScalar = 2;
|
||
|
Texture image = renderer.renderImage(scene, camera, 1920 * imageScalar, 1080 * imageScalar);
|
||
|
|
||
|
// Use post-processing Bloom effect
|
||
|
Bloom bloomEffect = Bloom(image.getImage());
|
||
|
Texture imageWithBloom = image;
|
||
|
imageWithBloom.setTexture(bloomEffect.bloom(0.55f, 5, 10.0f, 0.06f));
|
||
|
|
||
|
// save images
|
||
|
image.save("result.png");
|
||
|
imageWithBloom.save("resultWithBloom.png");
|
||
|
|
||
|
return 0;
|
||
|
}
|