From 66ea2e2c9ed4e9257521e6706fbd21feb7e3cc5b Mon Sep 17 00:00:00 2001 From: UjinT34 <41110182+UjinT34@users.noreply.github.com> Date: Thu, 16 Apr 2026 21:19:25 +0300 Subject: renderer: Various CM fixes, part 8 of refactors (#13860) Part 8 of Ujin's refactors. --- src/render/shaders/glsl/blur1.glsl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/render/shaders/glsl/blur1.glsl') diff --git a/src/render/shaders/glsl/blur1.glsl b/src/render/shaders/glsl/blur1.glsl index 36e7d660..86a37d88 100644 --- a/src/render/shaders/glsl/blur1.glsl +++ b/src/render/shaders/glsl/blur1.glsl @@ -100,10 +100,14 @@ vec4 blur1(vec2 v_texcoord, sampler2D tex, float radius, vec2 halfpixel, int pas vec2 uv = v_texcoord * 2.0; vec4 sum = texture(tex, uv) * 4.0; - sum += texture(tex, uv - halfpixel.xy * radius); - sum += texture(tex, uv + halfpixel.xy * radius); - sum += texture(tex, uv + vec2(halfpixel.x, -halfpixel.y) * radius); - sum += texture(tex, uv - vec2(halfpixel.x, -halfpixel.y) * radius); + // Those pixels might go outside the rendered area and grab some gabage. + // That garbage maps to 0.0-1.0 range with UINT8 buffer and doesn't have any significant impact on the end result. + // FP16 garbage maps to -65,504 - 65,504 and defines the end result. Clamp it here to 0.0 - 1.0 to get the same quality outcome as with UINT8. + // Rerendering an undamaged area to get some insignificant color accuracy increase on blur edges isn't worth it. + sum += clamp(texture(tex, uv - halfpixel.xy * radius), 0.0, 1.0); + sum += clamp(texture(tex, uv + halfpixel.xy * radius), 0.0, 1.0); + sum += clamp(texture(tex, uv + vec2(halfpixel.x, -halfpixel.y) * radius), 0.0, 1.0); + sum += clamp(texture(tex, uv - vec2(halfpixel.x, -halfpixel.y) * radius), 0.0, 1.0); vec4 color = sum / 8.0; -- cgit v1.2.3