Mixing multiples shaders in Eevee

Hello,

Let’s say I’ve got one paint shader and one metal shader and I want to do a scratched metal by mixing those two.
I know in cycles it’s better to have only one principled and mix color, rough metallic ect… with mix RGB.

I was wondering if it’s also the case with eevee or it behaves differently ?

Has someone as run some test on this side ? It would be way easier to mix shaders, but maybe I’m dreaming a bit here…

I believe they behave exactly the same.

You can think of it both ways; 1) principled as an object shader, or 2) principled as a material shader. If you have the texture resources to use it as an object shader, use it. If i.e. you only have a brick color and brick mask (brick grout not included in the texture), I would definitely use the mask to specify one material for brick and the other for grout.

Here is one that goes a step further - a bunch of objects (several hundreds) using the same material, but the material determines using object info/random which “slot” gets assigned. In this case I have 6 different materials (in yellow frames), plus one in light blue frame that is not part of the randomizing process. Yeah, I wish Blender had better multi material support to avoid this mess. But it works. Funny thing is, this actually works fine in Eevee as well as far as compiling goes. And there are lots of nested subgroups in here as well.

What you generally want to avoid if you can, is to mix two shaders when it is not needed. I.e. mixing two diffuse to get two colors will give two shader calls (expensive) compare to having the color precomputed in a color mix instead. Sometimes, like gradual mixing two principled (material and a specific coating or dust), you may not be able to avoid it. Same with mixing glossy roughnesses or glossy distributions - it’s expensive so use with care, but sometimes you have to.

2 Likes

hey thanks a lot for that elaborated answer !
That gives ideas of new possibilities !
I have run some test to see the difference between mixing shaders and mixing textures.


I’ve mixed 4 materials made of 3 textures each.

  • When I combine the shaders I get around 25ms to draw the scene
  • When I combine textures I get around 11ms

Memory wise it doesn’t seem to change, which seems logical.

So as you said, it’s better to avoid it when possible, but the sky won’t fall if we do it from time to time.
And it’s also true that sometimes this is unavoidable.

If you want better performances it’s better to mix textures, if you want faster and simpler setups mixing shaders is the way to go.

If you do it on a major player, like room walls, it’s going to matter. A 4 hour crunch may become an 8 hour crunch if enough of it is showing. It’s like chrome; you need two glossy to do it “right” - wrt roughness, one for the sharp peak and one for the very long tail (caused by diffraction effects). If you do product renders for faucets and absolutely wants this right, then maybe. Just maybe. For the rest of us, who cares? Proper roughness and bumps do way more to imitate good enough chrome plating.

1 Like

Yeah, I work in animation (series) and it’s better for me to have things optimized that run smooth at the cost of accuracy. Setup time is also important but I think it’s better to take time to make them right and copy-paste them all around the project.

I just wanted to be sure that I’m not completely wasting my time mixing textures :smiley:

If I really need it I’ll go with the mixing shader approach and it will be only on a few props, and there will be good reasons to do so …