materials: make lighting calculation shadow aware
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user