fix(scene): respect t for shadow rays
This commit is contained in:
parent
af4c4801f3
commit
c3d6d80fd7
@ -94,15 +94,18 @@ impl Scene {
|
|||||||
|
|
||||||
for light in &self.lights {
|
for light in &self.lights {
|
||||||
// Cast Shadow-Ray
|
// Cast Shadow-Ray
|
||||||
|
let direction = light.position - isect_pt;
|
||||||
|
let distance = direction.norm();
|
||||||
|
let direction = direction / distance;
|
||||||
let shadow_ray = Ray {
|
let shadow_ray = Ray {
|
||||||
origin: isect_pt,
|
origin: isect_pt,
|
||||||
direction: (light.position - isect_pt).normalize(),
|
direction,
|
||||||
};
|
};
|
||||||
if self
|
if self.objects.iter().any(|obj| {
|
||||||
.objects
|
obj.intersect(&shadow_ray)
|
||||||
.iter()
|
.and_then(|(_, _, t, _)| Some(t < distance))
|
||||||
.any(|obj| obj.intersect(&shadow_ray).is_some())
|
.unwrap_or(false)
|
||||||
{
|
}) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user