I have succeeded in getting ray hits on triangles for both the CPU and GPU on a few simple meshes. I am looking at the supported HitBuffer formats and I don’t see one that would tell me which ray hit my triangle. In the application I have in mind it is crucial to know the ray that hit the triangle. Any ideas?
Are you using OptiX Prime? You might need to use OptiX, which will give you the freedom to write your own HitBuffer format.
I am using OptiX Prime. I initially thought the hitBuffer only recorded hits of rays, but instead it actually records all ray casts and you know hits based on the hit “t” being positive or negative. That is, I think there is an explicit assumption here about the rayBuffer and the hitBuffer I did not catch at first glance. It appears the hitBuffer count and rayBuffer count are always the same - a one-to-one correspondence between hitBuffer index (i) and rayBuffer index (i). Is this true? If so, then when I walk the hitBuffer indices I can know the ray that caused the intersection due to the one-to-one correspondence.
“It appears the hitBuffer count and rayBuffer count are always the same - a one-to-one correspondence between hitBuffer index (i) and rayBuffer index (i). Is this true?”
See some other posts with answers to OptiX Prime questions: