mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-08-03 15:27:13 -04:00
Merge branch 'terrain_normals_fix' into 'master'
Fix terrain normal map handedness Closes #8610 See merge request OpenMW/openmw!4775
This commit is contained in:
commit
f4ff683905
@ -49,7 +49,7 @@ void main()
|
||||
vec2 adjustedUV = (gl_TextureMatrix[0] * vec4(uv, 0.0, 1.0)).xy;
|
||||
|
||||
#if @parallax
|
||||
adjustedUV += getParallaxOffset(transpose(normalToViewMatrix) * normalize(-passViewPos), texture2D(normalMap, adjustedUV).a, 1.f);
|
||||
adjustedUV += getParallaxOffset(transpose(normalToViewMatrix) * normalize(-passViewPos), texture2D(normalMap, adjustedUV).a, -1.0f);
|
||||
#endif
|
||||
vec4 diffuseTex = texture2D(diffuseMap, adjustedUV);
|
||||
gl_FragData[0] = vec4(diffuseTex.xyz, 1.0);
|
||||
|
@ -46,8 +46,8 @@ void main(void)
|
||||
normalToViewMatrix = gl_NormalMatrix;
|
||||
|
||||
#if @normalMap
|
||||
mat3 tbnMatrix = generateTangentSpace(vec4(1.0, 0.0, 0.0, 1.0), passNormal);
|
||||
tbnMatrix[0] = normalize(cross(tbnMatrix[2], tbnMatrix[1])); // note, now we need to re-cross to derive tangent again because it wasn't orthonormal
|
||||
mat3 tbnMatrix = generateTangentSpace(vec4(1.0, 0.0, 0.0, -1.0), passNormal);
|
||||
tbnMatrix[0] = -normalize(cross(tbnMatrix[2], tbnMatrix[1])); // our original tangent was not at a 90 degree angle to the normal, so we need to rederive it
|
||||
normalToViewMatrix *= tbnMatrix;
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user