Bounding volume Hierarchy bug

Hello Developers,

Its been while I am using optix. Right now I am working in participating media for heat transfer. I have faced one problem while I am using BVH builder/traverser. I have placed a set of cube after one another and was checking the intersections through each cube by emitting a ray from a single point and printing each intersection point.

Logically my ray has to go through each cube one by one and report intersections but there was a bug, it seems that the ray misses some of the intersections and go to the very next cube and then come back to the previous cube. This happened when I was using BVH builder. This problem have been solved by using MedianBvh, but I am curious that why I faced this problem? why the ray behaves like this?

Hi,
Not sure I understand this. Source code would help if you want to send something to optix-help (remember to rename the .zip extension to make it through the spam filters).

Are you saying that the closest hit program is not really giving you the closest hit? Or that the any-hit program is reporting intersections out of order? The first would be a bug, the second would not.

Hello . thank you for your response. Actually its the second one: any-hit program is reporting intersections out of order .

Sorry for the confusion though!
How can I fix that?

The order in which the anyhit program is invoked depends on the OptiX internal acceleration structure (AS) traversal you have no control over and which is different among AS builders.
Means you’re reyling on an implementation specific behavior in your algorithm which then won’t work generally. You need to implement a different algorithm to find all intersections along a ray in order.

Here are some descriptions of how to do that, one even for a similar topic as your work:
https://devtalk.nvidia.com/default/topic/930666/?comment=4857707

Related pseudo algorithms here: (Read the whole thread for pitfalls. I’d recommend the iterative method 2.)
https://devtalk.nvidia.com/default/topic/767646/?comment=4285917

Also mind that when your cubes are defined with coplanar faces next to each other, you might also need to implement a robust method to not skip any of the coplanar faces. Using a scene dependent epsilon to offset the next ray startpoint won’t work for that case.

Hello Detlef Roettger,

Thank you so much! I have implemented this iterative method 2. It is not only accurate but even faster. Thank you so much for your help!