2023-01-24 05:22:40 +01:00
|
|
|
#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"
|
2023-01-24 06:26:24 +01:00
|
|
|
#include "common/noise/perlinnoise.h"
|
|
|
|
#include "shader/noiseshader.h"
|
2023-01-24 06:44:20 +01:00
|
|
|
#include "common/noise/cloudnoise.h"
|
2023-01-24 11:31:09 +01:00
|
|
|
#include "light/sunlight.h"
|
2023-01-24 22:55:48 +01:00
|
|
|
#include "scene/simplescene.h"
|
|
|
|
#include "shader/refractionshader.h"
|
2023-01-24 05:22:40 +01:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
FastScene scene;
|
|
|
|
scene.setBackgroundColor(Color(0.529f, 0.808f, 0.922f));
|
|
|
|
|
|
|
|
// Add lights
|
2023-01-24 19:38:12 +01:00
|
|
|
auto mainLight = std::make_shared<SunLight>(Vector3d(-1.0f, -0.5f, -1.0f), 10.0f);
|
2023-01-24 05:22:40 +01:00
|
|
|
scene.add(mainLight);
|
|
|
|
scene.add(std::make_shared<AmbientLight>(0.3f));
|
|
|
|
|
|
|
|
// Add the bus
|
2023-01-24 22:55:48 +01:00
|
|
|
// 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));
|
2023-01-24 05:22:40 +01:00
|
|
|
|
|
|
|
// Add floor
|
2023-01-24 07:54:33 +01:00
|
|
|
auto floorShader = std::make_shared<SimpleShadowShader>(Color(0.9f, 0.9f, 0.9f));
|
2023-01-24 05:22:40 +01:00
|
|
|
scene.add(std::make_shared<InfinitePlane>(Vector3d(0.0f, 0.0f, 0.0f), Vector3d(0.0f, 1.0f, 0.0f),
|
2023-01-24 07:54:33 +01:00
|
|
|
floorShader));
|
2023-01-24 05:22:40 +01:00
|
|
|
|
|
|
|
// Add box for volume shader
|
|
|
|
auto cloudSettings = CloudSettings();
|
2023-01-24 11:18:03 +01:00
|
|
|
cloudSettings.scale = 15.0f;
|
|
|
|
cloudSettings.densityIntensity = 10.0f;
|
|
|
|
cloudSettings.densityTreshold = 0.49f;
|
|
|
|
cloudSettings.densityAbsorption = 0.9f;
|
2023-01-24 05:22:40 +01:00
|
|
|
auto cloudShader = std::make_shared<CloudShader>(cloudSettings);
|
2023-01-24 22:55:48 +01:00
|
|
|
scene.add(std::make_shared<Box>(Vector3d(20.0f, 8.0f, 20.0f), Vector3d(50.0f, 5.0f, 50.0f), cloudShader));
|
2023-01-24 05:22:40 +01:00
|
|
|
|
|
|
|
// build the tree
|
|
|
|
scene.buildTree();
|
|
|
|
|
|
|
|
// Set up the camera
|
|
|
|
PerspectiveCamera camera;
|
|
|
|
camera.setPosition(Vector3d(0.0f, 3.0f, 0.0f));
|
2023-01-24 22:55:48 +01:00
|
|
|
camera.setForwardDirection(normalized(Vector3d(1.0f, 0.15f, 1.0f)));
|
2023-01-24 05:22:40 +01:00
|
|
|
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;
|
|
|
|
}
|