[WIP] Add reflective parameter into material
This commit is contained in:
@@ -50,7 +50,7 @@ int shadow_sphere(uint8_t a_canvas_pixels, double a_wall_size, uint8_t a_wall_z)
|
||||
Tuple the_ray_origin = Tuple::Point(0, 0, -5);
|
||||
|
||||
double the_pixel_size = a_wall_size / a_canvas_pixels;
|
||||
double the_half = a_wall_size / 2;
|
||||
double the_half = a_wall_size / 2;
|
||||
double the_world_x, the_world_y;
|
||||
|
||||
// For each row of pixels in the canvas
|
||||
@@ -70,7 +70,7 @@ int shadow_sphere(uint8_t a_canvas_pixels, double a_wall_size, uint8_t a_wall_z)
|
||||
the_position -= the_ray_origin;
|
||||
Ray the_ray(the_ray_origin, the_position.normalize());
|
||||
|
||||
auto the_xs = the_shape.intersect(the_ray);
|
||||
auto the_xs = the_shape.intersect(the_ray);
|
||||
auto the_intersec = the_xs.hit();
|
||||
if (the_intersec.is_defined())
|
||||
{
|
||||
@@ -94,8 +94,8 @@ int main(void)
|
||||
printf("Chapter 05 example.\n");
|
||||
|
||||
the_start = chrono::high_resolution_clock::now();
|
||||
the_ret = shadow_sphere(kImageSize, kWallSize, kWallZ);
|
||||
the_end = chrono::high_resolution_clock::now();
|
||||
the_ret = shadow_sphere(kImageSize, kWallSize, kWallZ);
|
||||
the_end = chrono::high_resolution_clock::now();
|
||||
|
||||
chrono::duration<double> the_elapsed_time = the_end - the_start;
|
||||
printf("Execution Time: %f secondes\n", the_elapsed_time.count());
|
||||
|
||||
@@ -52,7 +52,7 @@ int shadow_sphere(uint8_t a_canvas_pixels, double a_wall_size, uint8_t a_wall_z)
|
||||
the_shape.material().set_color(Color(1, 0.2, 1));
|
||||
|
||||
double the_pixel_size = a_wall_size / a_canvas_pixels;
|
||||
double the_half = a_wall_size / 2;
|
||||
double the_half = a_wall_size / 2;
|
||||
double the_world_x, the_world_y;
|
||||
|
||||
// For each row of pixels in the canvas
|
||||
@@ -72,15 +72,15 @@ int shadow_sphere(uint8_t a_canvas_pixels, double a_wall_size, uint8_t a_wall_z)
|
||||
the_position -= the_ray_origin;
|
||||
Ray the_ray(the_ray_origin, the_position.normalize());
|
||||
|
||||
auto the_xs = the_shape.intersect(the_ray);
|
||||
auto the_xs = the_shape.intersect(the_ray);
|
||||
auto the_intersec = the_xs.hit();
|
||||
if (the_intersec.is_defined())
|
||||
{
|
||||
Tuple the_point = the_ray.position(the_intersec.distance_t());
|
||||
Tuple the_point = the_ray.position(the_intersec.distance_t());
|
||||
Tuple the_normal = the_intersec.object()->normal_at(the_point);
|
||||
Tuple the_eye = -the_ray.direction();
|
||||
Color the_color = the_intersec.object()->material().lighting(nullptr, the_light, the_point, the_eye,
|
||||
the_normal, false);
|
||||
Tuple the_eye = -the_ray.direction();
|
||||
Color the_color = the_intersec.object()->material().lighting(nullptr, the_light, the_point, the_eye,
|
||||
the_normal, false);
|
||||
the_canvas.write_pixel(x, y, the_color);
|
||||
}
|
||||
}
|
||||
@@ -101,8 +101,8 @@ int main(void)
|
||||
printf("Chapter 06 example.\n");
|
||||
|
||||
the_start = chrono::high_resolution_clock::now();
|
||||
the_ret = shadow_sphere(kImageSize, kWallSize, kWallZ);
|
||||
the_end = chrono::high_resolution_clock::now();
|
||||
the_ret = shadow_sphere(kImageSize, kWallSize, kWallZ);
|
||||
the_end = chrono::high_resolution_clock::now();
|
||||
|
||||
chrono::duration<double> the_elapsed_time = the_end - the_start;
|
||||
printf("Execution Time: %f secondes\n", the_elapsed_time.count());
|
||||
|
||||
@@ -107,9 +107,9 @@ int main(void)
|
||||
the_camera.set_transform(
|
||||
Matrix::view_transform(Tuple::Point(0, 1.5, -5), Tuple::Point(0, 1, 0), Tuple::Vector(0, 1, 0)));
|
||||
|
||||
the_start = chrono::high_resolution_clock::now();
|
||||
the_start = chrono::high_resolution_clock::now();
|
||||
the_canvas = the_camera.render(the_world);
|
||||
the_end = chrono::high_resolution_clock::now();
|
||||
the_end = chrono::high_resolution_clock::now();
|
||||
|
||||
the_canvas.save_to_file("chapter07.ppm");
|
||||
|
||||
|
||||
@@ -91,9 +91,9 @@ int main(void)
|
||||
the_camera.set_transform(
|
||||
Matrix::view_transform(Tuple::Point(0, 1.5, -3.5), Tuple::Point(0, 1, 0), Tuple::Vector(0, 1, 0)));
|
||||
|
||||
the_start = chrono::high_resolution_clock::now();
|
||||
the_start = chrono::high_resolution_clock::now();
|
||||
the_canvas = the_camera.render(the_world);
|
||||
the_end = chrono::high_resolution_clock::now();
|
||||
the_end = chrono::high_resolution_clock::now();
|
||||
|
||||
the_canvas.save_to_file("chapter09.ppm");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user