Search Unity

Question Getting instanced object index in compute shader using inline raytracing?

Discussion in 'Shaders' started by Pjbomb2, Mar 22, 2024.

  1. Pjbomb2

    Pjbomb2

    Joined:
    Jan 29, 2021
    Posts:
    39
    So my situation is this: I have a bunch of the same mesh I want to turn into instances. Using the RaytracingAccelerationStructure.AddInstances() is working fine
    However, my main use for them is in a compute shader that does inline raytracing queries, but I cannot find the api needed to get which instance in the group of instances the ray hits, is this missing or what do I need to do to access this? I need this because I have a seperate array of matrices that map to each instanced object, but I am unable to correctly index into this array of matrices since I am missing the ability to find out which instance I have hit with the rayquery. What am I missing? Thanks!