Material instance performance


I was curios about best way to use material instancing feature
I am asking because I have pretty complex master material with 3 static switches and a lot of constant parameters
So here is my questions

  1. How static switches react to performance? For example, I am using 2, one for Unique normal map and one Mask and I am using this mat on all my models, maybe it will be better to separate these materials by creating two master materials, one with static switches and one without for non unique models
  2. I have master material and for example, 50 material instances of this master mat,unique for each mesh, each of them with different parameters of color to achieve interesting look, does this approach harm the performance? Or it is better to use as low amount of mat instances as possible?
  3. This time question about blended mats, with vertex color, what if I will use it everywhere? It`s pretty simple, only blends two materials by splitting them with Vcolor.


I can’t give you any numbers or specific data, but I can tell you that I always use material instances as much as possible since it’s quite efficient. One of the latest scenes I’ve done (a shopping mall) contained about 70 materials, out of which about 45 were instances. I even use WorldAlignedTexture a lot (triplanar shading) even though it’s more expensive than normal UV-mapping, and I’ve had no problems whatsoever. I have a steady 120 fps+ and the scene has 130 animated characters, about 4000 meshes and cars and busses moving around. None of these things seem to burden the computer that much. Switches and stuff like that are very light on performance.

I would probably not make 50 versions of the same material though, seems like a lot of work. If you’re using instanced meshes, you can use the PerInstanceRandom node to randomize the color of each instance. One other thing you could do to get a little variation is to involve the object position in the colouring, so that you multiply your colour with a multiple of the world position. That will get you different colour on different objects, using just one material. It might take a bit of tweaking to make it look nice though.