Recursive Ray Traversal Algorithm - Traverse k-d Tree
I have chosen a stack based traversal algorithm (Recursive Ray Traversal Algorithm), and I am having a little trouble understanding it.
Here is what I understand.
I need to find a point where the ray enters the voxel (then calculate the distance ray origin and that point) where it exits (then calculate the distance between ray origin and that point), distance between ray origin and plane (in开发者_如何转开发 some papers I saw the formula:
(splitPoint - rayOrigin[currentAxle]) / rayOrientation[currentAxle]
My ray orientation is (0, 0, -1)
and then in some cases I will be dividing with zero (because x = 0
and y = 0
). How can this be?
And in the init of the algorithm, the ray origin is in the main voxel, how do I get the distance where the ray enters the voxel?
Do I understand this correctly? Can someone explain?
It's from the book "Physically Based Rendering From Theory to Implementation".
Two cases where both children of a node don’t need to be processed because the ray doesn’t overlap them.(a) The top ray intersects the splitting plane beyond the ray’s t_max position and thus doesn’t enter the far child. The bottom ray is facing away from the splitting plane, indicated by a negative t_split value.
(b) The ray intersects the plane before the ray’s t_min value, indicating that the near child doesn’t need processing.
精彩评论