From e4c5715b3f4f789319a9a4f583fb410085d64229 Mon Sep 17 00:00:00 2001 From: Valerie Date: Sun, 5 May 2024 17:20:01 -0400 Subject: [PATCH] retuned horizontal blur --- shaders/module/horizontal_blur.frag | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/shaders/module/horizontal_blur.frag b/shaders/module/horizontal_blur.frag index 9b8cc0b..e85d267 100644 --- a/shaders/module/horizontal_blur.frag +++ b/shaders/module/horizontal_blur.frag @@ -8,21 +8,16 @@ float avg(float l, float c, float r) { vec3 hblur() { vec3 center = texture2D(gcolor, texcoord).rgb; - vec2 leftPos = texcoord - neighborOffset; - vec2 rightPos = texcoord + neighborOffset; + vec3 sum = vec3(0); + int count = 0; + for(int x = -2; x < 2; x++) { + vec2 pos = texcoord - (neighborOffset * x); + if(pos.x >= 0 && pos.x < viewWidth) { + sum += texture2D(gcolor, pos).rgb; + count++; + } + } - vec3 left; - if(leftPos.x >= 0) - left = texture2D(gcolor, leftPos).rgb; - else - left = center; - - vec3 right; - if(rightPos.x >= 0) - right = texture2D(gcolor, rightPos).rgb; - else - right = center; - - return vec3(avg(left.r, center.r, right.r), avg(left.g, center.g, right.g), avg(left.b, center.b, right.b)); + return sum / count; }