summaryrefslogtreecommitdiff
path: root/src/render/shaders/glsl/blur1.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'src/render/shaders/glsl/blur1.glsl')
-rw-r--r--src/render/shaders/glsl/blur1.glsl12
1 files changed, 8 insertions, 4 deletions
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;