1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 15:29:55 +00:00

Reconstruct normal Z *properly*

This commit is contained in:
Alexei Kotov 2024-04-18 11:23:21 +03:00
parent e4c70b7861
commit 537964f8d8
4 changed files with 12 additions and 8 deletions

View file

@ -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);

View file

@ -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

View file

@ -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

View file

@ -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