Optix7 Intersection Attributes.


I was wondering if anyone knew how to pass a C struct from an intersection shader so that it can be collected in the AnyHit/Closest Hit shader via the use of optixReportIntersection.

optixReportIntersection is limited to only 8 ints.


Hi, I assume you need to pass back more than 32 bytes?

I haven’t tried this, but I think one way to do this is to pass a pointer to your struct in to your intersector, instead of passing the data out. Your struct could be located in raygen, or in memory. It seems a little awkward to have a geometry-specific struct in raygen, but I think it should work just fine.

One question to ask yourself is whether the data you’re trying to pass out of your intersector could be instead computed in your closest hit shader. For example, if you’re passing a normal vector back, then perhaps you could instead pass only the ray’s “t” value, and then in closest-hit reconstruct the hit point, and from the hit point reconstruct the surface normal using your primitive’s data.

If you can actually fit everything you need in 32 bytes, then I’d recommend packing your struct into the 8 attribute ints.


Hi David

Thanks for your response.
Yes after much thought it looks like it is best to compute in the closestHit from the hit record geom data.

I think documentation says not to pass in addresses to local memory to reportIntersection so declaring a local struct (though i tested and it appears to work) is not advised.
(i may be misunderstanding the Optix7 Doc)