How to mix shaders so that the sum is one.

In a node group I have , for example, a velvet shader, translucent shader and diffuse.
I’ve seen an example in the past where they add the values and then divide to get the sum of one.
Below a screenshot of what I remember, but for some reason I am breaking my head how to do it.
I know for some of you it might be very simple.
As group input I want to have Diffuse-Amount, Translucent amount and velvet amount. stc=1

Here a new attempt, which comes a bit closer, but still the last part is completely wrong.

the way to mix shaders equally, is not so complicated…
if you have two shaders, the mix factor should be .5
if 3 shaders, the first mix should be .5 and the second 0.6666 (or 0.3333 case you plug the first two in the bottom socket)
for 4 shaders, the last mix should be 0.75, and so on

here’s the logic:
we have shaders A, B, C, D; and you only have a mixshader that can use only 2 shaders.
you need to group them this way:
(((A * 0.5 + B * 0.5) * 0.666 + C * 0.333) * 0.75 + D * 0.25) = A0.25 + B0.25 + C0.25 + D0.25
(sorry for the math/algebra stuff :slight_smile: )

when you set the first mix factor to 0.5 you end up with 50/50% from each shaders. This 50/50% is 2/3 of the second mix, and the output of this mix will be 33/33/33%. Which is 3/4 of the third mix, 4/5 of the fourth mix, 5/6 of the fifth mix… so for any N shaders, the nth mix factor should be set to n/n+1

@Secrop, wow I understand the logic, surprisingly. And that is what I did intuitively but now I want to make a shader for other people who might get confused. I found out that actually the above node setup works. I had to turn on clamp.

Here the nodesetup, and the result. Suzanne shows what I am looking for a long time when making a shader for skin and fabrics. An important ingredient for me is a rough colored glossy without fresnel. On top of that I put a sharper gloss with fresnel ( PBR). I think I see this in a lot of organic things. So here on suzanne you see that orange glow, maybe I call it inner reflections ? And then the colorless surface reflections. Does that makes sense?

The Fresnel factor is always present in non conductive materials, but right now the fresnel node does not take roughness in consideration, and we can only fake the result with the help of the layerweight node, or to force the roughness into the normals information.

with very high roughness values, the fresnel effect will distribute the glossy rays more evenly over the surface (at its limit, you get a diffuse effect).

When dealing with more organic materials, it is common to have even more than just one glossy. This is because the surface will present different amounts of roughness at a microscale. Knowing the type of roughness your material has, will let you get a better aproximation of the amount different roughness glossys you need to mix.
There are some work being done to have the fresnel node to deal with different roughness values, and then we can have more accurate shaders… but for now, we must trust our perception, and it’s quite useless to say which is the perfect formula for these situations.

Interesting, do you know an example how to fake that result with the help of the layerweight node or how to force the roughness into the normals information? At the moment I am only familiar with cynicat pro’s reflection node.

I hear also a lot that a material is or metalic, or not. But then I wonder about things like hair. To me it seems there is something like a metalic gloss in or on it. (See also hair BSDF). Especially some carpets, and kimonos, sport sweaters. Here an example a bit exagerated, but I suppose you recognize it. I made it with a rough colored gloss, and a sharp colorless gloss. Only the sharper gloss has fresnel. stc=1

For the layerweight node, plug the ‘Facing’ output to a RGBCurve node, and eyeball the curve until you are satisfied with the results.
Forcing the roughness means using a noisy normal map to bypass the roughness distribution from the shader itself. This is a bit more complicated, but just because the a good normal map with a good distribution of normals in the facing hemisphere is hard to make (and also, it takes a bit more to converge, so more samples are needed).

I hear also a lot that a material is or metalic, or not. But then I wonder about things like hair. To me it seems there is something like a metalic gloss in or on it. (See also hair BSDF).

Hairs and some other fibers have normally a very organized micro structure, that results in some anisotropic reflections/refractions. But it’s not metalic, and the fresnel equation for non-conductive materials is still observable. Trying to break down the most important structure elements into different types of glossy (different roughness, anisotropic directions, etc) can give you some good results. But again, there’s no correct formula for this, since each hair type can have a different structure, and the fresnel node can’t deal with roughness even less with anisotrophy.

see latest blenderguru video on PBR

and also this one

this take care of the Fresnel function of roughness glossy and also of bump/ normal maps

happy bl


Thanks for the explanation, and I am getting a bit closer. So in my satin shader below I have to give the rough colored gloss a fresnel right? What I did was:

  • A mix of diffuse, tranlucent, Velvet, a colored gloss with rougness on 0.1 without fresnel.
  • On top of that a colorless sharper gloss with fresnel.
    So that is wrong then.

I am still confused about some things:

  • Diffuse is the same as rough gloss
  • A Diffuse has no fresnell on its own ( we can mix it with a sharper gloss with a fresnell )
    conclusion: diffuse is a metal, because it’s a gloss without fresnell. ( euh. I must be wrong. )
    Awh. there is still a lot to learn.

Yes I think I need to watch some tutorials about materials, I am quite confused at the moment about fresnel, diffuse, gloss and roughness. Thanks, I wanted to ask for good tutorials, but you are faster than me.