materials: make lighting calculation shadow aware

This commit is contained in:
2021-07-18 12:46:49 -07:00
parent efdc963a48
commit 1065702a5d
3 changed files with 24 additions and 8 deletions

View File

@@ -31,7 +31,7 @@ fn main() -> Result<()> {
let light_position = Tuple::point(-10., 10., -10.);
let light_color = WHITE;
let light = PointLight::new(light_position, light_color);
let in_shadow = false;
for y in 0..h {
let world_y = half - pixel_size * y as f32;
for x in 0..w {
@@ -44,7 +44,7 @@ fn main() -> Result<()> {
let point = r.position(hit.t);
let normal = hit.object.normal_at(point);
let eye = -r.direction;
let color = lighting(&hit.object.material, &light, point, eye, normal);
let color = lighting(&hit.object.material, &light, point, eye, normal, in_shadow);
c.set(x, y, color);
}
}