Open junior-stack opened 8 months ago
That confuses me because I think when the ray origin lies inside the box, we sometimes need to have ray_intersect_box returns true, even through this lead to negative txmin, tymin and tzmin. Consider the case when the ray origin lies inside the box of the root of AABB Tree Node
if the ray or
min_t
lands inside the box this could still hit something stored inside the box, so this counts as a hit
you are right, for rays inside a box it should count as a hit.
So in this case, we have negative txmin but we return true. In conclusion, we should first check if ray origin is inside the box and if so, we return true. If not, we compute tvalues and compare it with the min_t and max_t?
Also, suppose the ray origin lies in the inside of the box, this could potentially lead to negative txmin or tymin or tzmin, do we also return false in this case?
Actually, why would a ray inside a box return negative t? Given the box is solid, wouldn't t = 0?
If not, we compute tvalues and compare it with the min_t and max_t?
Yes.
The way I calculate t
is based of the formula of the textbook, which is (xmin - xe) / xd
. As you can imagine, if the ray origin lies inside the box, it would give me a negative value and thus the whole function return false
pg. 299 algorithm doesn't show the case where the ray is inside a box -- if the box is solid, then the ray inside a box gives t_min = 0 and t_max = 0. Consider Figure. 12.24, with the ray origin in the solid box, the interval shrinks to a point on the real line.
Of course, consider this case as a special case is fine.
For
ray_intersect_box
, when we compute negative txmin, tymix, tzmin using the method from textbook p302, do we return false in this function? Also, suppose the ray origin lies in the inside of the box, this could potentially lead to negative txmin or tymin or tzmin, do we also return false in this case?