mouse-based picking

Hi everyone,

I am currently using Optix to render a 3D scene. I am trying to figure out a nice way to do mouse picking using the same Optix context. Basically from the pixel coordinates I can throw a single ray using the same ray generation program but with a different ray type. This is the easy part. What I don’t know is how to get the id of the object with the closest hit and return it. The 3D object can be either spheres but also triangle meshes (in which case it would be nice to get back the mesh id, the triangle id and the barycentric coordinates).

Thank you in advance for your help.

When you say return it, do you mean from the intersection kernel to the closest hit? For that you can use an attribute variable. Otherwise I’m not sure specifically what you’re asking.