Can someone explain why the check is "if (hit2.t < closest.t)"? It seems to be like it should be whichever hit corresponds to child2.
rilakkuma
closest.t may be updated by find_closest_hit(ray, first, closest) (checking the primitives in the first bounding box), so if closest.t (time hitting the current recorded closest primitive) is larger than hit2.t (time hitting the second bounding box), we should still check if there is primitive in the second bounding box that might be closer.
OillyNoodle
I am confused with the figure in the slide and the two intersect function calls. In the figure the two rays are in reverse direction, but when we pass the same "ray" as arguments in the two calls. How should I interpret it as one from front and the other from the back?
fbrsk
Wouldn't the closest.t be equal to hit1.t if the ray doesn't hit anything inside the first bounding box? And if then the hit2.t < closest.t would never satisfy? How is the closest.t updated if it doesn't hit anything inside?
wenere
Same here. I suppose line 7 should be NVHNode* second = (hi1.t <= hit2.t) ? child2 : child1;
Max
The idea here is to check if the ray intersects a primitive in the first bounding box before it has entered the second bounding box, as in this case we don't have to check anything in the second box.
@OillyNoodle we're running the whole function on one ray at a time - the figure just illustrates that this plays out differently depending on the ray.
@fbrsk closest.t would only be updated if the ray intersects a real primitive (i.e. in the leaf part of the conditional)
@wenere yeah
qiqinl
But what will happen if hit1 and hit2 both fail (the ray just didn't hit anything), what's the point of comparing hit1.t and hit2.t then?
heethesh
Shouldn't hit1 and hit2 be swapped if (hit1.t > hit2.t) as hit2.t will no longer correspond to *second and hit1.t is what we are supposed to be checking?
RyuK
@heethesh I think they should be swapped i.e max of the two(hit1 and hit2) should be used in the if operation.
Can someone explain why the check is "if (hit2.t < closest.t)"? It seems to be like it should be whichever hit corresponds to child2.
closest.t may be updated by find_closest_hit(ray, first, closest) (checking the primitives in the first bounding box), so if closest.t (time hitting the current recorded closest primitive) is larger than hit2.t (time hitting the second bounding box), we should still check if there is primitive in the second bounding box that might be closer.
I am confused with the figure in the slide and the two intersect function calls. In the figure the two rays are in reverse direction, but when we pass the same "ray" as arguments in the two calls. How should I interpret it as one from front and the other from the back?
Wouldn't the closest.t be equal to hit1.t if the ray doesn't hit anything inside the first bounding box? And if then the hit2.t < closest.t would never satisfy? How is the closest.t updated if it doesn't hit anything inside?
Same here. I suppose line 7 should be NVHNode* second = (hi1.t <= hit2.t) ? child2 : child1;
The idea here is to check if the ray intersects a primitive in the first bounding box before it has entered the second bounding box, as in this case we don't have to check anything in the second box.
@OillyNoodle we're running the whole function on one ray at a time - the figure just illustrates that this plays out differently depending on the ray.
@fbrsk closest.t would only be updated if the ray intersects a real primitive (i.e. in the leaf part of the conditional)
@wenere yeah
But what will happen if hit1 and hit2 both fail (the ray just didn't hit anything), what's the point of comparing hit1.t and hit2.t then?
Shouldn't hit1 and hit2 be swapped if (hit1.t > hit2.t) as hit2.t will no longer correspond to *second and hit1.t is what we are supposed to be checking?
@heethesh I think they should be swapped i.e max of the two(hit1 and hit2) should be used in the if operation.