1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-10-15 14:56:36 +00:00

Don't overcorrect parallax Y

This commit is contained in:
Alexei Kotov 2025-08-25 10:21:17 +03:00
parent 944925663d
commit b011b81d77
3 changed files with 5 additions and 7 deletions

View file

@ -126,13 +126,10 @@ void main()
#if @parallax || @diffuseParallax #if @parallax || @diffuseParallax
#if @parallax #if @parallax
float height = texture2D(normalMap, normalMapUV).a; float height = texture2D(normalMap, normalMapUV).a;
float flipY = (passTangent.w > 0.0) ? -1.f : 1.f;
#else #else
float height = texture2D(diffuseMap, diffuseMapUV).a; float height = texture2D(diffuseMap, diffuseMapUV).a;
// FIXME: shouldn't be necessary, but in this path false-positives are common
float flipY = -1.f;
#endif #endif
offset = getParallaxOffset(transpose(normalToViewMatrix) * normalize(-passViewPos), height, flipY); offset = getParallaxOffset(transpose(normalToViewMatrix) * normalize(-passViewPos), height);
#endif #endif
vec2 screenCoords = gl_FragCoord.xy / screenRes; vec2 screenCoords = gl_FragCoord.xy / screenRes;

View file

@ -49,7 +49,8 @@ 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.0f); float height = texture2D(normalMap, adjustedUV).a;
adjustedUV += getParallaxOffset(transpose(normalToViewMatrix) * normalize(-passViewPos), height);
#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);

View file

@ -4,9 +4,9 @@
#define PARALLAX_SCALE 0.04 #define PARALLAX_SCALE 0.04
#define PARALLAX_BIAS -0.02 #define PARALLAX_BIAS -0.02
vec2 getParallaxOffset(vec3 eyeDir, float height, float flipY) vec2 getParallaxOffset(vec3 eyeDir, float height)
{ {
return vec2(eyeDir.x, eyeDir.y * flipY) * ( height * PARALLAX_SCALE + PARALLAX_BIAS ); return vec2(eyeDir.x, -eyeDir.y) * ( height * PARALLAX_SCALE + PARALLAX_BIAS );
} }
#endif #endif