What is it that Layer Weight node's Facing output is supposed to be?

In the source code, if blend is less than 0.5 then pow(cos(N,I), 2*blend) is used instead.

@MartinZ, if you want to have a normalized value between the cos(N,I), then instead of the LayerWeigth node, you can use pow((1-dot(N,I), 2). That will give you a linear value between cos(N,I)=0 and cos(N,I)=1.

Thank you Secrop, that’s interesting and makes all even more complicate :), but the formula above is not the same as the output of the node, it should rather be for converting ‘blend’ values to IOR.

paolo

that was just part of the formula…
For the layer value output, here’s the complete formula:


if blend in [0.0, 0.5[:
    result = 1 - pow(dot(N,I), 2*blend)
if blend == 0.5:
    result = 1 - dot(N,I)
if blend in ]0.5, 1.0[:
    result = 1 - pow(dot(N,I), 0.5/(1-blend))

note there are clampings everywhere and the blend value never gets to reach 1.0, as it’s clamped to 0.9999 (1.0 - 10^-5)

How can I control layer weight with principled shader ?

You would use it like you do with any other shader.

For example if you wanted the base colour of the Principled shader to change with viewing angle - you would plug the Layer weight node into a colour ramp - then plug the colour ramp into the base colour slot of the Principled shader.


yeah, I supposed that, so even the conversion formula never gives NaN, however you can see that for values of blend near 1 the IOR value tends to +infinite, that’s not plausible.

Thank you very much for your reply.

OK so I get the angle like this: arccos(pow(1-dot(N, I), 2)) then it’s in range 0° - 90°, right? So I would map it to range 0 to 1 by dividing everything by 90.

So I get linear range of facing values from 0 to 1 by arccos(pow(1-dot(N, I), 2))/90, right? and yet:

So the answer is that I shouldn’t have skipped those maths lessons at school after all.

Thanks Moony.

Oh, OK, so after I realized I needed some more learning to do (thanks to Khans academy) and some experimentation:

https://s24.postimg.org/5fyv8c2yt/Capture.png

Because the angle between two normalized vectors is arccos(·) and it does not need to be expressed in degrees. So this is Camera Facing Angle expressed linearly - finally. If you plug it to RGB Curves you get custom Fresnel curve. :slight_smile: Cool.

I guess, thanks everybody for being with me during my learning process. :smiley:

Looks pretty good. Might lead to more logical control than the facing or fresnel

I don’t get how Fresnel’s curves are calculated though. Is it Schlick’s approximation? IOR seems to be chosen randmly in Blender in some places as well. Maybe another day…