- Home /
Is having many instances of the same material bad for performances?
I have some sprite renderers that use instances of the same material so that every sprite renderer can have its own parameters for the shader.
Does it degrade in any manner the performances?
Answer by tencnivel · Dec 25, 2018 at 03:27 PM
yes but I am not exactly using the same material because I'm cloning it like the following:
spriteRenderer1.material = Instantiate<Material>(sourceMaterial);
spriteRenderer2.material = Instantiate<Material>(sourceMaterial);
...
I am worried that multiplying the instances of this material may impact the performances. If that is the case I will try to have the sprite renderers share the minimun number of instances of the source material.
Answer by CarpeFunSoftware · Dec 29, 2018 at 12:40 AM
Check the documentation for "Material property block" and try to use the same material. Then it can be instanced and all drawn in one draw call (but I'm not 100% sure on sprite renderers. I suppose I should make a test before shooting my mouth off, but I'm being lazy).
Anyway, the MPB info will give you an idea. And all this impacts batching/instancing.
https://docs.unity3d.com/Manual/GPUInstancing.html
Also see draw-call batching (indicates that sprite renderers are batched) https://docs.unity3d.com/Manual/DrawCallBatching.html
But they have to share the same material instance.
Your answer
Follow this Question
Related Questions
Same texture in different materials performance 2 Answers
Are transparent shaders more efficient when they're 100% opaque? 1 Answer
Material doesn't have a color property '_Color' 4 Answers
Very slow performance when I use scalled quad on a mobile device. 0 Answers
Shader performance question. 0 Answers