In what situation will the if statement be true? (second child's min_t is closer than closest.min_t, given that first has a smaller min_t)
dvernet
I believe this could happen if the ray doesn't intersect with a primitive in the first child's BVH. The if statement you're referring to is basically a logical short circuit, i.e.:
if (the ray didn't intersect with anything in in the first child's BVH) {
see if it intersects with anything in the second child's
}
Khryl
I think the if statement will be true even if the ray intersects with a primitive in the first child BVH. Because there is a overlap in space between the first and second child BVHs, some primitives in the second child BVH can still be "in front of" the primitive intersected by the ray in the first child BVH. Note that it's closest.min_t in the if statement, not min_t1.
kayvonf
Everyone: thanks for the fix. Your understanding is correct. The slide has changed from:
find_closest_hit(ray, node->child2, closest)
to
find_closest_hit(ray, second, closest)
Please refresh.
kayvonf
@Khryl: nice answer. You are correct. When the bounding boxes of the two children overlap, just because you find a hit in the "closer" child visited, that does not mean there cannot be an even closer hit in the other child.
The "closer" child is only closer in that the ray enters that child's bounding box first. This does not mean that a primitive hit in this node is guaranteed to be closer than a primitive hit in the other node.
dvernet
So this seems like a gigantic cost / inefficiency to have in the algorithm. Why would you not always use something like a quadtree (or maybe a variation on that like a KD tree, but really just any type of data structure with non overlapping partitions)? Is it because it's harder to compute the distance to a primitive if it's split into different partitions?
Khryl
Actually, it's not going to be a very huge cost. Because we only need to check the second child BVH if the intersection in the first child BVH happens in the overlapping region(only this region will have closest.min_t > second_child.min_t). We can see from the lecture above that hit in the overlapping region is not very likely.
kayvonf
Correct. Except you meant second_child.min_t < closest.min_t.
kayvonf
@dvernet: Spatial-partitioning structures have their own problems, see see slide 30.
dvernet
It looks like we're not returning or skipping a recursive call if hit1 or hit2 are false. Is that a bug in the pseudocode?
In what situation will the if statement be true? (second child's min_t is closer than closest.min_t, given that first has a smaller min_t)
I believe this could happen if the ray doesn't intersect with a primitive in the first child's BVH. The if statement you're referring to is basically a logical short circuit, i.e.:
if (the ray didn't intersect with anything in in the first child's BVH) {
}
I think the if statement will be true even if the ray intersects with a primitive in the first child BVH. Because there is a overlap in space between the first and second child BVHs, some primitives in the second child BVH can still be "in front of" the primitive intersected by the ray in the first child BVH. Note that it's closest.min_t in the if statement, not min_t1.
Everyone: thanks for the fix. Your understanding is correct. The slide has changed from:
to
Please refresh.
@Khryl: nice answer. You are correct. When the bounding boxes of the two children overlap, just because you find a hit in the "closer" child visited, that does not mean there cannot be an even closer hit in the other child.
The "closer" child is only closer in that the ray enters that child's bounding box first. This does not mean that a primitive hit in this node is guaranteed to be closer than a primitive hit in the other node.
So this seems like a gigantic cost / inefficiency to have in the algorithm. Why would you not always use something like a quadtree (or maybe a variation on that like a KD tree, but really just any type of data structure with non overlapping partitions)? Is it because it's harder to compute the distance to a primitive if it's split into different partitions?
Actually, it's not going to be a very huge cost. Because we only need to check the second child BVH if the intersection in the first child BVH happens in the overlapping region(only this region will have closest.min_t > second_child.min_t). We can see from the lecture above that hit in the overlapping region is not very likely.
Correct. Except you meant
second_child.min_t < closest.min_t
.@dvernet: Spatial-partitioning structures have their own problems, see see slide 30.
It looks like we're not returning or skipping a recursive call if hit1 or hit2 are false. Is that a bug in the pseudocode?