Hi,
Shader replacement is not working for material of mesh rendered using Graphics.DrawMeshInstancedIndirect() . But it’s working for normal gameobjects in scene with any shader.
How to make it work for Graphics.DrawMeshInstancedIndirect() ?
Thankyou for the reply.
Both the replacement shader and already present shader for instanced indirect mesh are vert frag shaders. So I am not using any setup function as per unity doc here.
Finally what I want is bloom effect for only the objects (which are drawn with Graphics.DrawMeshInstancedIndirect()) with particular shader. So, I am trying to achieve it using replacement shaders.
when drawing instanced indirect each instance does not have the unity_ObjectToWorld and unity_WorldToObject set. This you need to do in a function spesified by the #pragma instancing_options procedural:setup
in this case a function called setup.
This function has to be present on the replacement shaders you try to use. If not it will render all instances with “empty” matrixes.
the setup function needs to set the same values as the original shader you are replacing does. The materials also need to to have the same compute buffers etc.
How can I access what values I assigned to original shader? If possible , can you please provide sample replacement shader that works for unity example of Graphics.DrawMeshInstancedIndirect() given here.
If you wanted to make another shader replacing the one in your link it needs this section.
In addition to what the shader normally would do.
But remember this will change depending on what the original shader does and how it calculates the matrixes.
You can not make an generic replacement shader that works for all instanced indirect implementations.