Hi.
Basicly, i have a decal shader that i use on GPU instancing with DrawnMeshInstanced.
And i want to make them randomly select texture from texture atlas, by chaning UV like (0,0) (0,0.5f) etc.
I planed to change their UV based on world position is even or not, because decals don’t move. However, this randomized system doesn’t work. Because when one of the decal is changed all of the decals are change to same texture, instead of that one who moves.
Only the right one should have changed but the left one changed too.
When i disable the GPU instancing on material everthing works fine. But i need to open it so i can use this on DrawMesh funciton.
I don’t know the problem is the getting world position of the object, or the _randomUV is shared on every decal instead of calculated on each one.
I suspect the issue is you’re not passing the instance ID from the vertex shader to the fragment shader, so the unity_ObjectToWorld in the fragment shader is always the one for the first instance. You need to use the appropriate macros to pass the value and initialize it in the fragment shader.
See the “Vertex and fragment shader example” on this page:
Yep, this is the whole code. I added “UNITY_SETUP_INSTANCE_ID(i);” on frag_mult just now, it wasn’t there before.
But no changes, i tried to move it after the baseWorldPos calculated but still no changes.