- Home /
Material Property Blocks don't work with Replacement Shaders?
Hi! I'm trying to set a Color Property with Per Renderer Data using Material Property Blocks and then trying to read that Color Property's Per Renderer Data value with a Replacement Shader. I am succeeding in setting the Property Block correctly (I've confirmed that the Property Block maintains the correct color values across frames), but the Replacement Shader seems to ignore the Material Property Block values.
I've also confirmed that I get the desired behavior with my Replacement Shader when I use Material's SetColor function instead of MaterialPropertyBlock's SetColor function so that doesn't seem to be the issue. Of course this means generating a new Material Instance per object using this Material which is terrible for my performance since I render tons of these objects and depend on the batching optimization from Per Renderer Data + Property Blocks.
Has anyone run into this and do you know a workaround? Is this a bug that I should be reporting? (I am using 2019.4.17),I have a Per Renderer Data Color Property that I would like to use in a replacement shader, but it seems that when I use MaterialPropertyBlock's SetColor Function nothing happens even though I have confirmed that the Property Block is indeed being set correctly and maintains the correct value through to the following frame.
When I use Material's SetColor Function, I get the behavior I am looking for, with the exception that I am now generating tons of Material Instances since I this function does not leverage the Per Renderer Data batching functionality.
Does anyone know how to get around this issue or should I just report this as a bug? (I'm using 2019.4.17)
Your answer
![](https://koobas.hobune.stream/wayback/20220613025309im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How do I set the MaterialPropertyBlock for terrain grass? 0 Answers
MaterialPropertyBlock ignored when rendering with replaced shaders? 0 Answers
DrawMesh and MaterialPropertyBlock 0 Answers
How to set GameObject inactive without messing up GPU instancing? 0 Answers
Replacement shaders in Virtual Reality -1 Answers