How to sample a Mesh in Metal Ray-tracing Structure.

I am learning Accelerating ray tracing using Metal. The area light has its own struct in this sample code, but I want to sample rays directly from the LightMesh. Can I get the instances and geometry of lightMesh without using resources buffer? It seems the geometries are already loaded in the GPU because Metal3 is able to do the intersection test. However, I can only get primitive_data during the intersection, and cannot get the information when I tried to do sampling.

Thanks a lot!

I think what you are asking is how to get the geometry you put into an acceleration structure back when you are processing the intersection. If it is what you are asking, there's currently no way to do that. Instead, as you said, you would need to pass some sort of argument buffer that would contain that geometry.

That's exactly what I ask. Thank you. I passed the resource buffer and the instance index, so that I can access the geometry. :)

How to sample a Mesh in Metal Ray-tracing Structure.
 
 
Q