#include #include #include #include #include #include #include #include #include #include #include #include #include //#include #include #include #include #include #include #include #include #include #include #include #include "scene/fastscene.h" #include "shader/toneshader.h" #include "renderer/superrenderer.h" int main() { FastScene scene; scene.setEnvironmentMap(std::make_shared("data/clear_blue_sky.jpg")); // Light // Alternative directio Vector3d(0, -.5f, -.5f) auto mainLight = std::make_shared(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( std::make_shared(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(cloudSettings); scene.add(std::make_shared(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 = 1; Texture image = renderer.renderImage(scene, camera, 1920 * imageScalar, 1080 * imageScalar); image.save("result.png"); // Use post-processing Bloom effect Bloom bloomEffect = Bloom(image.getImage(), 0.88f, image); image.setTexture(bloomEffect.bloom(50, 20.0f, 0.5f)); image.save("resultWithBloom.png"); return 0; }