From b011b81d77d3cd69e8ae88eb629260d5da6bda4b Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Mon, 25 Aug 2025 10:21:17 +0300 Subject: [PATCH] Don't overcorrect parallax Y --- files/shaders/compatibility/objects.frag | 5 +---- files/shaders/compatibility/terrain.frag | 3 ++- files/shaders/lib/material/parallax.glsl | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/files/shaders/compatibility/objects.frag b/files/shaders/compatibility/objects.frag index ad6d262f6d..2e3ea795fb 100644 --- a/files/shaders/compatibility/objects.frag +++ b/files/shaders/compatibility/objects.frag @@ -126,13 +126,10 @@ void main() #if @parallax || @diffuseParallax #if @parallax float height = texture2D(normalMap, normalMapUV).a; - float flipY = (passTangent.w > 0.0) ? -1.f : 1.f; #else float height = texture2D(diffuseMap, diffuseMapUV).a; - // FIXME: shouldn't be necessary, but in this path false-positives are common - float flipY = -1.f; #endif - offset = getParallaxOffset(transpose(normalToViewMatrix) * normalize(-passViewPos), height, flipY); + offset = getParallaxOffset(transpose(normalToViewMatrix) * normalize(-passViewPos), height); #endif vec2 screenCoords = gl_FragCoord.xy / screenRes; diff --git a/files/shaders/compatibility/terrain.frag b/files/shaders/compatibility/terrain.frag index 48183c0a92..d206b9028f 100644 --- a/files/shaders/compatibility/terrain.frag +++ b/files/shaders/compatibility/terrain.frag @@ -49,7 +49,8 @@ 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.0f); + float height = texture2D(normalMap, adjustedUV).a; + adjustedUV += getParallaxOffset(transpose(normalToViewMatrix) * normalize(-passViewPos), height); #endif vec4 diffuseTex = texture2D(diffuseMap, adjustedUV); gl_FragData[0] = vec4(diffuseTex.xyz, 1.0); diff --git a/files/shaders/lib/material/parallax.glsl b/files/shaders/lib/material/parallax.glsl index 5525281f75..524244cdf8 100644 --- a/files/shaders/lib/material/parallax.glsl +++ b/files/shaders/lib/material/parallax.glsl @@ -4,9 +4,9 @@ #define PARALLAX_SCALE 0.04 #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