mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-08-04 07:46:40 -04:00
fix terrain normal map handedness
This commit is contained in:
parent
c232ad55b4
commit
869881d227
@ -49,7 +49,7 @@ void main()
|
|||||||
vec2 adjustedUV = (gl_TextureMatrix[0] * vec4(uv, 0.0, 1.0)).xy;
|
vec2 adjustedUV = (gl_TextureMatrix[0] * vec4(uv, 0.0, 1.0)).xy;
|
||||||
|
|
||||||
#if @parallax
|
#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
|
#endif
|
||||||
vec4 diffuseTex = texture2D(diffuseMap, adjustedUV);
|
vec4 diffuseTex = texture2D(diffuseMap, adjustedUV);
|
||||||
gl_FragData[0] = vec4(diffuseTex.xyz, 1.0);
|
gl_FragData[0] = vec4(diffuseTex.xyz, 1.0);
|
||||||
|
@ -46,8 +46,8 @@ void main(void)
|
|||||||
normalToViewMatrix = gl_NormalMatrix;
|
normalToViewMatrix = gl_NormalMatrix;
|
||||||
|
|
||||||
#if @normalMap
|
#if @normalMap
|
||||||
mat3 tbnMatrix = generateTangentSpace(vec4(1.0, 0.0, 0.0, 1.0), passNormal);
|
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
|
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;
|
normalToViewMatrix *= tbnMatrix;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user