Hello!
I’m working on a project where some assets reuse the same material, kinda normal. However, I was wondering, what (if any) would be the performance impact of having two materials that are the same, just named material one and material two? Would it double the impact, or does unity have some sort of built-in instancing since both materials would fetch the exact same texture file?
Yes both materials would reference the exact same texture so you won’t pay any extra memory there.
What you might pay is a slight cost of storing and building the properties for the new material (all depending on platform and project settings)
Be careful you also will get a small CPU slowdown because you break rendering batches more often ( you can check that in the frame debugger ). Because two different material instances break the internal rendering batch loop ( even if both materials have the exact same values)
If you’re using a new Scriptable Render Loop ( as Lightweight of HD pipeline ) then you don’t have this limitation anymore. You can create tons of different material instances ( even with different values for each material ) and you still have maximum CPU performance. ( you just have to enable “SRP batcher” in this case )
Hi, I have a question. For example let say I have 1000 models in my game and all of them use same material with different tilling/offset! (all names changes to instanced) Is this good for performance or bad? Will this use more GPU memory or less?
Or it’s better if I set 100 different materials with totally different textures? Instead of 1000 with same textures only different tilling and offset?
The SRP Batcher helps minimize the cost of swapping materials as long as they all use the exact same shader, so using material instances vs completely separate materials really shouldn’t change much. That said, using multiple different textures means you have to get more textures on to GPU memory, which will absolutely take up more memory than using a single texture, so you are better off with changing the tiling/offset rather than swapping so many textures.
Ideally, however, if all your models are identical you might want to look into instancing if things prove too slow for you.