From 6fb361e9a65c01a70ab6dcf9faa4300438535b71 Mon Sep 17 00:00:00 2001 From: fretuks Date: Fri, 14 Nov 2025 19:45:25 +0100 Subject: [PATCH] Fix shader underwater --- .../mindmotion/shaders/program/desaturate.fsh | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/main/resources/assets/mindmotion/shaders/program/desaturate.fsh b/src/main/resources/assets/mindmotion/shaders/program/desaturate.fsh index cc0728a..86c3e44 100644 --- a/src/main/resources/assets/mindmotion/shaders/program/desaturate.fsh +++ b/src/main/resources/assets/mindmotion/shaders/program/desaturate.fsh @@ -2,9 +2,9 @@ uniform sampler2D DiffuseSampler; uniform float Desat; -uniform float BlurAmount; // NEW -uniform float Vignette; // NEW -uniform float FogStrength; // NEW +uniform float BlurAmount; +uniform float Vignette; +uniform float FogStrength; in vec2 texCoord; in vec2 oneTexel; @@ -14,8 +14,7 @@ out vec4 fragColor; vec4 sampleBlur() { if (BlurAmount <= 0.001) return texture(DiffuseSampler, texCoord); - // lighter blur kernel - float w = BlurAmount * 0.5; // reduce strength globally + float w = BlurAmount * 0.5; vec4 sum = vec4(0.0); sum += texture(DiffuseSampler, texCoord + oneTexel * vec2(-1, 0)) * w; @@ -23,7 +22,6 @@ vec4 sampleBlur() { sum += texture(DiffuseSampler, texCoord + oneTexel * vec2( 0, -1)) * w; sum += texture(DiffuseSampler, texCoord + oneTexel * vec2( 0, 1)) * w; - // center weight higher to avoid total smudge vec4 center = texture(DiffuseSampler, texCoord) * (1.0 - w * 4.0); return center + sum; @@ -32,19 +30,16 @@ vec4 sampleBlur() { void main() { vec4 col = texture(DiffuseSampler, texCoord); vec4 blurred = sampleBlur(); - col = mix(col, blurred, BlurAmount); // Apply blur + col = mix(col, blurred, BlurAmount); - // Apply grayscale/desat float gray = dot(col.rgb, vec3(0.2126, 0.7152, 0.0722)); col.rgb = mix(col.rgb, vec3(gray), clamp(Desat, 0.0, 1.0)); - // Fog: push color toward light gray col.rgb = mix(col.rgb, vec3(0.75, 0.75, 0.8), FogStrength); - // Vignette (darken edges) float dist = distance(texCoord, vec2(0.5, 0.5)); float vign = smoothstep(0.3, 0.7, dist); col.rgb = mix(col.rgb, col.rgb * 0.4, vign * Vignette); - fragColor = col; + fragColor = vec4(col.rgb, 1.0); } \ No newline at end of file