Material Layer Instances are way more expensive?

Hi guys,

I have build up my shaders with the material layer system, which is [out of beta since 4.26][1] and I really like the modular approach, but my main problem is the performance with these.

I created a master shader for all my basic assets with very few shader instructions.
As you can see, the shader itself is pretty complex, but a lot of features are behind a static switch so you can enable for example fuzzy shading only if you need it. So basically in this shape here right now, it’s just few textures plugged in with some extra option for normal intensity, roughness contrast etc.

I have 33 base shader and 42 vertex shader instructions. Low cost … but when I create an instance based on this material layer, it’s boost up to 255/333 instructions for the base shader. This is super expensive for one layer.

342068-instructions2.jpg

Is this a bug or do I do something wrong?
Thanks for your help :slight_smile:

Material layer preview shows instruction count specific to this layer. When you put it into context of actual base pass shader, it does have more instructions indeed. That is normal. Material layers are indeed expensive and you can’t expect going wild with them.

So just referencing them in a material layer blend costs this much?
In my example it’s just really this one layer. So I wonder what’s the actualy usage of them when it’s so expensive to use. Of course, when you layer 10 materials on top of another it becomes very pricey, but even 2-3 layers went to deep red.

Yes, even two three layers are that expensive. Depending of course on what you put in the layers, but generally yes.