Merge branch 'actuallynormalnormalz' into 'master'

Reconstruct normal Z *properly*

See merge request OpenMW/openmw!4036
pull/3235/head
psi29a 8 months ago
commit b072b9e54b

@ -77,10 +77,11 @@ void main()
vec3 specularColor = getSpecularColor().xyz;
#if @normalMap
vec4 normalTex = texture2D(normalMap, normalMapUV);
vec3 normal = normalTex.xyz * 2.0 - 1.0;
#if @reconstructNormalZ
normalTex.z = sqrt(1.0 - dot(normalTex.xy, normalTex.xy));
normal.z = sqrt(1.0 - dot(normal.xy, normal.xy));
#endif
vec3 viewNormal = normalToView(normalTex.xyz * 2.0 - 1.0);
vec3 viewNormal = normalToView(normal);
specularColor *= normalTex.a;
#else
vec3 viewNormal = normalize(gl_NormalMatrix * passNormal);

@ -60,10 +60,11 @@ void main()
#if @normalMap
vec4 normalTex = texture2D(normalMap, normalMapUV);
vec3 normal = normalTex.xyz * 2.0 - 1.0;
#if @reconstructNormalZ
normalTex.z = sqrt(1.0 - dot(normalTex.xy, normalTex.xy));
normal.z = sqrt(1.0 - dot(normal.xy, normal.xy));
#endif
vec3 viewNormal = normalToView(normalTex.xyz * 2.0 - 1.0);
vec3 viewNormal = normalToView(normal);
#else
vec3 viewNormal = normalToView(normalize(passNormal));
#endif

@ -168,10 +168,11 @@ vec2 screenCoords = gl_FragCoord.xy / screenRes;
#if @normalMap
vec4 normalTex = texture2D(normalMap, normalMapUV + offset);
vec3 normal = normalTex.xyz * 2.0 - 1.0;
#if @reconstructNormalZ
normalTex.z = sqrt(1.0 - dot(normalTex.xy, normalTex.xy));
normal.z = sqrt(1.0 - dot(normal.xy, normal.xy));
#endif
vec3 viewNormal = normalToView(normalTex.xyz * 2.0 - 1.0);
vec3 viewNormal = normalToView(normal);
#else
vec3 viewNormal = normalize(gl_NormalMatrix * passNormal);
#endif

@ -64,10 +64,11 @@ void main()
#if @normalMap
vec4 normalTex = texture2D(normalMap, adjustedUV);
vec3 normal = normalTex.xyz * 2.0 - 1.0;
#if @reconstructNormalZ
normalTex.z = sqrt(1.0 - dot(normalTex.xy, normalTex.xy));
normal.z = sqrt(1.0 - dot(normal.xy, normal.xy));
#endif
vec3 viewNormal = normalToView(normalTex.xyz * 2.0 - 1.0);
vec3 viewNormal = normalToView(normal);
#else
vec3 viewNormal = normalize(gl_NormalMatrix * passNormal);
#endif

Loading…
Cancel
Save