[WIP] Add reflective parameter into material
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user