Hello,
I am using Graphics.DrawMeshInstancedIndirect to render instances of a cube in my scene, and passing a unique transformation matrix to each instance. A computebuffer stores the transformation matrices (created using matrix.trs in c#), the matrices are edited in compute shader, and then the final shader applied to the mesh reads from this buffer of matrices and assigns the appropriate matrix using InstanceId as the index.
HOWEVER, while this works to transform the instanced mesh, I am noticing that it does not update GetWorldToObjectMatrix() for each instance. For example, I am using this matrix in the fragment shader to make an adjustment texture coordinates. The method works just fine using a regular mesh that doesn’t use a structuredbuffer to look up transformation matrix. The appropriate behavior is: when I rotate my object, the texture coordinates also rotate.
However, in the case where I am instancing with DrawMeshInstancedIndirect, the GetWorldToObjectMatrix() seems to do nothing at all. The instanced meshes all rotate correct, but the texture is not affected.
How do I get a similar function that updates in accordance with my per-instance transformation matrix?