From eafb2947cc523f3ff7f3ecbb549ce5a034270166 Mon Sep 17 00:00:00 2001 From: CJSatnarine Date: Thu, 11 Jul 2024 14:32:33 -0400 Subject: [PATCH] Final scene --- main.cpp | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/main.cpp b/main.cpp index b7707bf..6ebebbc 100644 --- a/main.cpp +++ b/main.cpp @@ -322,6 +322,77 @@ void cornellSmoke() { cam.render(world); } +void finalScene(int imageWidth, int samplesPerPixel, int maxDepth) { + hittableList boxes1; + + auto ground = make_shared(colour(0.48, 0.83, 0.53)); + + int boxesPerSide = 20; + for (int i = 0; i < boxesPerSide; i++) { + for (int j = 0; j < boxesPerSide; j++) { + auto w = 100.0; + auto x0 = -1000.0 + i*w; + auto z0 = -1000.0 + j*w; + auto y0 = 0.0; + auto x1 = x0 + w; + auto y1 = randomDouble(1,101); + auto z1 = z0 + w; + + boxes1.add(box(point3(x0,y0,z0), point3(x1,y1,z1), ground)); + } + } + + hittableList world; + + auto light = make_shared(colour(7, 7, 7)); + world.add(make_shared(point3(123, 554, 147), vec3(300, 0, 0), vec3(0, 0, 265), light)); + + auto centre1 = point3(400, 400, 200); + auto centre2 = centre1 + vec3(30, 0, 0); + auto sphereMaterial = make_shared(colour(0.7, 0.3, 0.1)); + world.add(make_shared(centre1, centre2, 50, sphereMaterial)); + + world.add(make_shared(point3(260, 150, 45), 50, make_shared(1.5))); + world.add(make_shared(point3(0, 150, 145), 50, make_shared(colour(0.8, 0.8, 0.9), 1.0))); + + auto boundary = make_shared(point3(360,150,145), 70, make_shared(1.5)); + world.add(boundary); + world.add(make_shared(boundary, 0.2, colour(0.2, 0.4, 0.9))); + boundary = make_shared(point3(0,0,0), 5000, make_shared(1.5)); + world.add(make_shared(boundary, .0001, colour(1,1,1))); + + auto emat = make_shared(make_shared("earthmap.jpg")); + world.add(make_shared(point3(400,200,400), 100, emat)); + auto pertext = make_shared(0.2); + world.add(make_shared(point3(220,280,300), 80, make_shared(pertext))); + + hittableList boxes2; + auto white = make_shared(colour(.73, .73, .73)); + int ns = 1000; + for (int j = 0; j < ns; j++) { + boxes2.add(make_shared(point3::random(0,165), 10, white)); + } + + world.add(make_shared(make_shared(make_shared(boxes2), 15), vec3(-100,270,395))); + + camera cam; + + cam.aspectRatio = 1.0; + cam.imageWidth = imageWidth; + cam.samplesPerPixel = samplesPerPixel; + cam.maxDepth = maxDepth; + cam.background = colour(0,0,0); + + cam.vFieldOfView = 40; + cam.lookFrom = point3(478, 278, -600); + cam.lookAt = point3(278, 278, 0); + cam.vUp = vec3(0,1,0); + + cam.defocusAngle = 0; + + cam.render(world); +} + int main(void) { int sceneToShow = 9; @@ -353,5 +424,11 @@ int main(void) { case 9: cornellSmoke(); break; + case 10: + finalScene(800, 10000, 40); + break; + default: + finalScene(400, 250, 4); + break; } } \ No newline at end of file