#include #include #include "camera/perspectivecamera.h" #include "renderer/simplerenderer.h" #include "scene/simplescene.h" #include "primitive/box.h" #include "primitive/infiniteplane.h" #include "primitive/objmodel.h" #include "primitive/sphere.h" #include "shader/brdfshader.h" #include "shader/lambertshader.h" #include "shader/mirrorshader.h" #include "shader/phongshader.h" #include "shader/cooktorranceshader.h" #include "renderer/depthoffieldrenderer.h" #include "light/ambientlight.h" #include "light/pointlight.h" #include "light/spotlight.h" #include "post_processing/bloom.h" int main() { // Let's create a simple scene... SimpleScene scene; // Set up the camera PerspectiveCamera camera; camera.setFovAngle(90.0f); camera.setPosition(Vector3d(0.0f, 0.0f, -10.0f)); camera.setForwardDirection(Vector3d(0.0f, 0.0f, 1.0f)); camera.setUpDirection(Vector3d(0.0f, 1.0f, 0.0f)); // Add shaders auto mirror = std::make_shared(); auto white = std::make_shared(Color(0.9f, 0.9f, 0.9f)); auto red = std::make_shared(Color(1.0f, 0.3f, 0.2f)); auto blue = std::make_shared(Color(0.2f, 0.3f, 1.0f)); auto orange = std::make_shared(Color(1.0f, 0.64f, 0.0f), 1.0f, Color(1.0f, 1.0f, 1.0f), 1.0f, 25.0f); auto gold= std::make_shared(Color(0.83f, 0.69f, 0.22f), Color(1.0f, 1.0f, 0.0f), 1.2f, 0.2f); auto blueMetallic = std::make_shared("../data/blue-metallic-paint.binary", Color(7.0f, 7.0f, 7.0f)); auto darkRed = std::make_shared("../data/dark-red-paint.binary", Color(7.0f, 7.0f, 7.0f)); // Set up the walls // --------------------------------------------------------------------------- scene.add(std::make_shared(Vector3d(0.0f, 0.0f, +5.0f), Vector3d(0.0f, 0.0f, -1.0f), mirror)); scene.add(std::make_shared(Vector3d(0.0f, 0.0f, -5.0f), Vector3d(0.0f, 0.0f, +1.0f), mirror)); scene.add(std::make_shared(Vector3d(0.0f, +5.0f, 0.0f), Vector3d(0.0f, -1.0f, 0.0f), white)); scene.add(std::make_shared(Vector3d(0.0f, -5.0f, 0.0f), Vector3d(0.0f, +1.0f, 0.0f), white)); scene.add(std::make_shared(Vector3d(+5.0f, 0.0f, 0.0f), Vector3d(-1.0f, 0.0f, 0.0f), blue)); scene.add(std::make_shared(Vector3d(-5.0f, 0.0f, 0.0f), Vector3d(+1.0f, 0.0f, 0.0f), red)); scene.add(std::make_shared(Vector3d(-3.0f, 0.0f, 0.0f), 1.0f, blueMetallic)); scene.add(std::make_shared(Vector3d(0.0f, 2.0f, 0.0f), 1.0f, orange)); scene.add(std::make_shared(Vector3d(3.0f, 0.0f, 0.0f), 1.0f, darkRed)); scene.add(std::make_shared(Vector3d(-3.0f, -3.3f, -4.0f), 1.0f, mirror)); // Add the teapot auto teapot = std::make_shared(gold); teapot->loadObj("../data/teapot.obj", Vector3d(3.0f, 3.0f, 3.0f), Vector3d(0.0f, -5.0f, 0.0f)); scene.add(teapot); // Add ambient light scene.add(std::make_shared(0.15f)); //scene.add(std::make_shared(Vector3d(0.0f, 4.0f, -4.0f), 15.0f)); scene.add(std::make_shared(Vector3d(0.0f, 2.5f, -4.0f), 7.0f)); // Render the scene // SimpleRenderer renderer; // renderer.renderImage(scene, camera, 1024, 1024).save("result.png"); // initialize renderer: aperture = lens thickness, secondaryRayCount = how many rays per pixel are created // focalLength = the area which is in focus DOFRenderer renderer(0.2, 100, 10.0f); // Use DOFRenderer to raytrace !!! careful more pixels lead to insane rendering times Texture image = renderer.renderImage(scene, camera, 1024, 1024); // save images image.save("result.png"); return 0; }