Skip to content

Commit

Permalink
Added final scene
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Jorquera committed Mar 29, 2024
1 parent 9916aea commit 032fb93
Showing 1 changed file with 69 additions and 1 deletion.
70 changes: 69 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,74 @@ void cornell_smoke() {
camera.render(scene, "image.png");
}

void final_scene(int image_width, int samples_per_pixel, int max_depth) {
shared_ptr<Scene> boxes1 = make_shared<Scene>();
auto ground = make_shared<Lambertian>(Color(0.48, 0.83, 0.53));

int boxes_per_side = 20;
for (int i = 0; i < boxes_per_side; i++) {
for (int j = 0; j < boxes_per_side; 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(createBox(Point(x0,y0,z0), Point(x1,y1,z1), ground));
}
}

shared_ptr<Scene> scene = make_shared<Scene>();

scene->add(make_shared<Bvh>(boxes1->intersectables()));

auto light = make_shared<DiffuseLight>(Color(7, 7, 7));
scene->add(make_shared<Quad>(Point(123,554,147), Vector(300,0,0), Vector(0,0,265), light));

auto center1 = Point(400, 400, 200);
auto center2 = center1 + Vector(30,0,0);
auto sphere_material = make_shared<Lambertian>(Color(0.7, 0.3, 0.1));
scene->add(make_shared<Sphere>(center1, center2, 50, sphere_material));

scene->add(make_shared<Sphere>(Point(260, 150, 45), 50, make_shared<Dielectric>(1.5)));
scene->add(make_shared<Sphere>(
Point(0, 150, 145), 50, make_shared<Metal>(Color(0.8, 0.8, 0.9), 1.0)
));

auto boundary = make_shared<Sphere>(Point(360,150,145), 70, make_shared<Dielectric>(1.5));
scene->add(boundary);
scene->add(make_shared<ConstantMedium>(boundary, 0.2, Color(0.2, 0.4, 0.9)));
boundary = make_shared<Sphere>(Point(0,0,0), 5000, make_shared<Dielectric>(1.5));
scene->add(make_shared<ConstantMedium>(boundary, .0001, Color(1,1,1)));

auto emat = make_shared<Lambertian>(make_shared<ImageTexture>("earthmap.jpg"));
scene->add(make_shared<Sphere>(Point(400,200,400), 100, emat));
auto pertext = make_shared<NoiseTexture>(0.1);
scene->add(make_shared<Sphere>(Point(220,280,300), 80, make_shared<Lambertian>(pertext)));

shared_ptr<Scene> boxes2 = make_shared<Scene>();
auto white = make_shared<Lambertian>(Color(.73, .73, .73));
int ns = 1000;
for (int j = 0; j < ns; j++) {
boxes2->add(make_shared<Sphere>(Point::random(0,165), 10, white));
}

scene->add(make_shared<Translate>(
make_shared<RotateY>(
make_shared<Bvh>(boxes2->intersectables()), 15),
Vector(-100,270,395)
)
);

Camera camera(1.0, samples_per_pixel, max_depth, image_width, 40.0, Point(478, 278, -600), Point(278, 278, 0), Vector(0.0, 1.0, 0.0), Color(0.0, 0.0, 0.0), 0.0);

camera.render(scene, "image.png");
}

int main() {
switch (8) {
switch (9) {
case 1: randomSpheres(); break;
case 2: twoSpheres(); break;
case 3: earth(); break;
Expand All @@ -206,6 +272,8 @@ int main() {
case 6: simple_light(); break;
case 7: cornell_box(); break;
case 8: cornell_smoke(); break;
case 9: final_scene(800, 10000, 40); break;
default: final_scene(400, 250, 4); break;
}
return 0;
}

0 comments on commit 032fb93

Please sign in to comment.