Fix T42492, Shading error with fresnel weight node.

Orthographic case needs different handling.
This commit is contained in:
Antonis Ryakiotakis 2014-11-06 15:03:34 +01:00
parent 5e01e71b59
commit d1eb762b57
Notes: blender-bot 2023-02-14 09:51:53 +01:00
Referenced by issue #42492, Shading bug with Material shading in orthographic view
1 changed files with 4 additions and 2 deletions

View File

@ -2274,10 +2274,12 @@ void node_layer_weight(float blend, vec3 N, vec3 I, out float fresnel, out float
{
/* fresnel */
float eta = max(1.0 - blend, 0.00001);
fresnel = fresnel_dielectric(normalize(I), N, (gl_FrontFacing)? 1.0/eta : eta );
vec3 I_view = (gl_ProjectionMatrix[3][3] == 0.0)? normalize(I): vec3(0.0, 0.0, -1.0);
fresnel = fresnel_dielectric(I_view, N, (gl_FrontFacing)? 1.0/eta : eta );
/* facing */
facing = abs(dot(normalize(I), N));
facing = abs(dot(I_view, N));
if(blend != 0.5) {
blend = clamp(blend, 0.0, 0.99999);
blend = (blend < 0.5)? 2.0*blend: 0.5/(1.0 - blend);