Final scene
This commit is contained in:
77
main.cpp
77
main.cpp
@@ -322,6 +322,77 @@ void cornellSmoke() {
|
|||||||
cam.render(world);
|
cam.render(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void finalScene(int imageWidth, int samplesPerPixel, int maxDepth) {
|
||||||
|
hittableList boxes1;
|
||||||
|
|
||||||
|
auto ground = make_shared<lambertian>(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<diffuseLight>(colour(7, 7, 7));
|
||||||
|
world.add(make_shared<quad>(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<lambertian>(colour(0.7, 0.3, 0.1));
|
||||||
|
world.add(make_shared<sphere>(centre1, centre2, 50, sphereMaterial));
|
||||||
|
|
||||||
|
world.add(make_shared<sphere>(point3(260, 150, 45), 50, make_shared<dielectric>(1.5)));
|
||||||
|
world.add(make_shared<sphere>(point3(0, 150, 145), 50, make_shared<metal>(colour(0.8, 0.8, 0.9), 1.0)));
|
||||||
|
|
||||||
|
auto boundary = make_shared<sphere>(point3(360,150,145), 70, make_shared<dielectric>(1.5));
|
||||||
|
world.add(boundary);
|
||||||
|
world.add(make_shared<constantMedium>(boundary, 0.2, colour(0.2, 0.4, 0.9)));
|
||||||
|
boundary = make_shared<sphere>(point3(0,0,0), 5000, make_shared<dielectric>(1.5));
|
||||||
|
world.add(make_shared<constantMedium>(boundary, .0001, colour(1,1,1)));
|
||||||
|
|
||||||
|
auto emat = make_shared<lambertian>(make_shared<imageTexture>("earthmap.jpg"));
|
||||||
|
world.add(make_shared<sphere>(point3(400,200,400), 100, emat));
|
||||||
|
auto pertext = make_shared<noiseTexture>(0.2);
|
||||||
|
world.add(make_shared<sphere>(point3(220,280,300), 80, make_shared<lambertian>(pertext)));
|
||||||
|
|
||||||
|
hittableList boxes2;
|
||||||
|
auto white = make_shared<lambertian>(colour(.73, .73, .73));
|
||||||
|
int ns = 1000;
|
||||||
|
for (int j = 0; j < ns; j++) {
|
||||||
|
boxes2.add(make_shared<sphere>(point3::random(0,165), 10, white));
|
||||||
|
}
|
||||||
|
|
||||||
|
world.add(make_shared<translate>(make_shared<rotateY>(make_shared<bvh_node>(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 main(void) {
|
||||||
int sceneToShow = 9;
|
int sceneToShow = 9;
|
||||||
|
|
||||||
@@ -353,5 +424,11 @@ int main(void) {
|
|||||||
case 9:
|
case 9:
|
||||||
cornellSmoke();
|
cornellSmoke();
|
||||||
break;
|
break;
|
||||||
|
case 10:
|
||||||
|
finalScene(800, 10000, 40);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
finalScene(400, 250, 4);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user