cloudy-raytracer/fancy1.cpp

78 lines
2.7 KiB
C++

#include <iostream>
#include <string>
#include "camera/perspectivecamera.h"
#include "scene/fastscene.h"
#ifdef SUPERRENDERER_FOUND
#include "renderer/superrenderer.h"
#endif
#include "light/ambientlight.h"
#include "light/pointlight.h"
#include "shader/toneshader.h"
#include "primitive/infiniteplane.h"
#include "shader/simpleshadowshader.h"
#include "primitive/box.h"
#include "shader/cloudshader.h"
#include "common/noise/perlinnoise.h"
#include "shader/noiseshader.h"
#include "common/noise/cloudnoise.h"
#include "light/sunlight.h"
#include "scene/simplescene.h"
#include "shader/refractionshader.h"
int main()
{
FastScene scene;
scene.setBackgroundColor(Color(0.529f, 0.808f, 0.922f) * 1.0f);
// Add lights
auto mainLight = std::make_shared<SunLight>(Vector3d(-1.0f, -0.5f, -1.0f), 5.0f, Color(1, 0.79f, 0.62f));
scene.add(mainLight);
// scene.add(std::make_shared<AmbientLight>(0.3f));
// auto light = std::make_shared<PointLight>(Vector3d(25.0f, 10.0f, 25.0f), 100.0f);
// scene.add(light);
// Add the bus
// auto busShader = std::make_shared<ToneShader>(mainLight);
// scene.addObj("data/Bus/source/T07-11M.obj", Vector3d(1.0f, 1.0f, 1.0f), Vector3d(15.0f, 0.0f, 10.0f),
// busShader);
// Refraction boxes
auto boxShader = std::make_shared<RefractionShader>(1.05f, 1, Color(1,1,0), 0.7f);
scene.add(std::make_shared<Box>(Vector3d(5.0f, 3.0f, 10.0f), Vector3d(3.0f, 3.0f, 3.0f), boxShader));
auto boxShader1 = std::make_shared<RefractionShader>(1.05f, 1, Color(0,1,1), 0.7f);
scene.add(std::make_shared<Box>(Vector3d(9.0f, 3.0f, 12.0f), Vector3d(3.0f, 3.0f, 3.0f), boxShader1));
// Add floor
auto floorShader = std::make_shared<SimpleShadowShader>(Color(0.9f, 0.9f, 0.9f));
scene.add(std::make_shared<InfinitePlane>(Vector3d(0.0f, 0.0f, 0.0f), Vector3d(0.0f, 1.0f, 0.0f),
floorShader));
// Add box for volume shader
auto cloudSettings = CloudSettings();
cloudSettings.scale = 15.0f;
auto cloudShader = std::make_shared<CloudShader>(cloudSettings);
scene.add(std::make_shared<Box>(Vector3d(20.0f, 10.0f, 20.0f), Vector3d(50.0f, 10.0f, 50.0f), cloudShader));
// build the tree
scene.buildTree();
// Set up the camera
PerspectiveCamera camera;
camera.setPosition(Vector3d(0.0f, 3.0f, 0.0f));
camera.setForwardDirection(normalized(Vector3d(1.0f, 0.15f, 1.0f)));
camera.setUpDirection(normalized(Vector3d(0.0f, 1.0f, 0.0f)));
camera.setFovAngle(90.0f);
// Render the scene
SuperRenderer sr;
sr.setSuperSamplingFactor(1);
sr.renderImage(scene, camera, 1024, 1024).save("result.png");
return 0;
}