Merge pull request #20941 from codingHahn/fix-normals-on-shader

Fix handling of normals that approach 1
This commit is contained in:
Rémi Verschelde 2018-08-15 08:40:16 +02:00 committed by GitHub
commit 4c6cf97257
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -526,7 +526,7 @@ FRAGMENT_SHADER_CODE
#if defined(ENABLE_NORMALMAP)
normalmap.xy = normalmap.xy * 2.0 - 1.0;
normalmap.z = sqrt(1.0 - dot(normalmap.xy, normalmap.xy));
normalmap.z = sqrt(max(0.0, 1.0 - dot(normalmap.xy, normalmap.xy)));
// normal = normalize(mix(normal_interp, tangent * normalmap.x + binormal * normalmap.y + normal * normalmap.z, normaldepth)) * side;
normal = normalmap;

View file

@ -1700,7 +1700,7 @@ FRAGMENT_SHADER_CODE
#if defined(ENABLE_NORMALMAP)
normalmap.xy=normalmap.xy*2.0-1.0;
normalmap.z=sqrt(1.0-dot(normalmap.xy,normalmap.xy)); //always ignore Z, as it can be RG packed, Z may be pos/neg, etc.
normalmap.z=sqrt(max(0.0, 1.0-dot(normalmap.xy,normalmap.xy))); //always ignore Z, as it can be RG packed, Z may be pos/neg, etc.
normal = normalize( mix(normal_interp,tangent * normalmap.x + binormal * normalmap.y + normal * normalmap.z,normaldepth) ) * side;