Optix 7 return shape ID

optixGetPrimitiveIndex()is able to return the triangle ID for each shape in cuda. Is there way to return the shape ID in cuda? for example I have three mesh build in optix, and when I reach closehit I want to know the ID of the current shape.

Hi @kyan8, you may be looking for optixGetInstanceId():



I tried this but it seems the value is always -1
btw all the mesh are triangle_mesh and I didn’t use Instance build inputs

In that case you should also have three Shader Binding Table entries, and that would be the place where you could store your shape ID.