Duplicate hits on the same triangle in any-hit program?

I’m seeing the same position on the same triangle occasionally get hit multiple times for a single ray in an any-hit program. What could be causing this? I’m running optixIgnoreIntersection every time in the any-hit program, but I still wouldn’t expect it to hit the same triangle twice and this is causing problems.

Here’s some print output from the any-hit program for an example ray showing duplicate hits on the same triangle:

Launch index 0, origin 0.265714 -0.020000 -0.734286, back face hit 1, hit 0.265714 -0.020000 -0.051340, tmax 0.682946, instance index 0, gas index 42, primitive index 3
Launch index 0, origin 0.265714 -0.020000 -0.734286, back face hit 0, hit 0.265714 -0.020000 -0.463696, tmax 0.270589, instance index 0, gas index 42, primitive index 1
Launch index 0, origin 0.265714 -0.020000 -0.734286, back face hit 1, hit 0.265714 -0.020000 -0.051340, tmax 0.682946, instance index 0, gas index 42, primitive index 3
Launch index 0, origin 0.265714 -0.020000 -0.734286, back face hit 0, hit 0.265714 -0.020000 0.765561, tmax 1.499846, instance index 0, gas index 2, primitive index 0
Launch index 0, origin 0.265714 -0.020000 -0.734286, back face hit 1, hit 0.265714 -0.020000 1.164358, tmax 1.898644, instance index 0, gas index 2, primitive index 2

Hi @ambyld, welcome!

It is normal for the any-hit shader to be allowed to execute more than once by default. This can happen for multiple reasons, depending on which primitive type and your BVH settings.

To guarantee a single any-hit call for a primitive, please use OPTIX_GEOMETRY_FLAG_REQUIRE_SINGLE_ANYHIT_CALL.


David.

2 Likes

Ah I see, I wasn’t aware of that. This fixed the issue, thank you David!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.