Fix handling of normals that approach 1

This commit is contained in:
Nick Hahn 2018-08-12 12:45:43 +02:00
parent 64595f0f6a
commit 66eba18969
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;