Write an "Intersection Program" that takes into account the type of ray traced (primary, ambient occlusion, GI, ....)

Good morning, I am trying to add “Displace maps” to my Optix raytracer.
I have taken a cue from your demo “NVidia Displacement Demo” and adapted it to my program (see image)
Getting to the question, currently the meshes are split and extruded during the intersection program.
This results in my program being slow when it calculates GI (for example) so I would like to “turn off” the “Subdivide and Displace” function based on the type of ray I am drawing (primary, reflection, ambient occlusion, GI,…)
I saw that the varibaile “rtPayload” is not accessible in an Intersection Program.
Any suggestions on how to do this?
Thank you very much
Antonio

Unfortunately that is not possible with the OptiX 6 API.
Intersection programs are per Geometry and there is no per-ray control over its behavior.

This limitation does not exist in the OptiX 7 API where the optixGetPayload device functions are available inside the intersection program.
Additionally the intersection program is part of the hit record inside the Shader Binding Table (SBT) which also allows implementing completely separate intersection programs per ray type which can be selected via the SBT offset (4 bits) in optixTrace for each ray.

A general performance issue with this approach will be that you’re not going to be able to use built-in hardware triangle primitives which are fully hardware accelerated on RTX boards otherwise.

Then there are also these features coming: Opacity Micro Maps (OMM) and Displacement Micro Meshes (DMM)

If displacement is a feature you require, it would be a good time to port your application over to the OptiX 7 API which would allow you to implement what you asked for above and to make use of DMM in the future.

1 Like