What do you thing is better for performance?:
One complex material and a lot instances or more simple material and less instances?
I have a scene with 3 or 4 complex materials:
For PBR textures
And for these i make more than 50 instances but there are many objects what not take advantage all attributes of the material.
The quastion is… You thing is better to make more simple and specific material and less instances? or i stay how i’m
PD: All instances have a parent material not other instance.
Instances don’t give you any better performance as far as I know. They are only meant for making it easier for you to work with the materials. So regarding performance its best to use materials that are as simple as possible.
Complexity as it pertains to (rendering) performance is dictated by instruction count, (dynamic) parameter counts and texture samplers used in the resulting shader/s.
Complexity of the expression graph of the material is not necessarily a one to one relationship to the cost of the shader/s.
The reason for that depends on the use of static switch parameters, and their use in MICs (material instance constants). Static switch parameters control what aspects of the material graph are compiled into the shader, so for example you could have an expression graph made up of 1,000 expressions, and if you have a static switch parameter path that excludes all of that and your using that path in your MIC, well that MIC would have the exact same rendering cost as if the material did not have those 1,000 expressions.
Note however that I am explicitly referring to rendering cost in this example. There are other costs of course, many of which are interrelated.
Mats, MICs, and MIDs, what combination of these is ideal?
Well to answer that you have to be aware of one of the benefits of material instances (beyond their productivity benefit), that being the sharing of material shaders. In other words 2 MICs can behind the scenes share the same shader while still having differing (dynamic) params (scalar/vec/tex). There are many benefits to this sharing optimization of the engine:
reduces number of material shaders needed to compile
reduces number needed to load
reduces total memory cost of shaders
I like to refer to each unique instance of a material (as dictated by static switch params in the MICs) as a permutation.
Personally I’m quite new to ue4, but I have immense experience with ue3, and from what I have seen thus far the material system is extremely similar.
One limitation ue3 had was that if you duplicate a material, and used both on content, then that would be compiled out as two unique permutations, in other words materials cannot share with each other, only MICs/MIDs can share with each other. I assume ue4 has this same limitation. This in other words makes it even more of a bad idea to have thousands of simple materials instead of a single ‘complex’ material with thousands of MICs that use static switches to use only what they need to use…
There is more to it of course, like usage flags, blend/lighting models/modes, and of course the cost of the parameters, but getting the most out of those is perhaps beyond the scope of this thread.