From cbfb7af7fd4728f993124e81f8666a2e8cee6085 Mon Sep 17 00:00:00 2001 From: Erik Reider <35975961+ErikReider@users.noreply.github.com> Date: Mon, 17 Apr 2023 23:24:48 +0200 Subject: Add kawase blur (#120) Co-authored-by: Erik Reider Co-authored-by: Will McKinnon --- sway/desktop/fx_renderer/shaders/blur2.frag | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 sway/desktop/fx_renderer/shaders/blur2.frag (limited to 'sway/desktop/fx_renderer/shaders/blur2.frag') diff --git a/sway/desktop/fx_renderer/shaders/blur2.frag b/sway/desktop/fx_renderer/shaders/blur2.frag new file mode 100644 index 00000000..3755a294 --- /dev/null +++ b/sway/desktop/fx_renderer/shaders/blur2.frag @@ -0,0 +1,22 @@ +precision mediump float; +varying mediump vec2 v_texcoord; +uniform sampler2D tex; + +uniform float radius; +uniform vec2 halfpixel; + +void main() { + vec2 uv = v_texcoord / 2.0; + + vec4 sum = texture2D(tex, uv + vec2(-halfpixel.x * 2.0, 0.0) * radius); + + sum += texture2D(tex, uv + vec2(-halfpixel.x, halfpixel.y) * radius) * 2.0; + sum += texture2D(tex, uv + vec2(0.0, halfpixel.y * 2.0) * radius); + sum += texture2D(tex, uv + vec2(halfpixel.x, halfpixel.y) * radius) * 2.0; + sum += texture2D(tex, uv + vec2(halfpixel.x * 2.0, 0.0) * radius); + sum += texture2D(tex, uv + vec2(halfpixel.x, -halfpixel.y) * radius) * 2.0; + sum += texture2D(tex, uv + vec2(0.0, -halfpixel.y * 2.0) * radius); + sum += texture2D(tex, uv + vec2(-halfpixel.x, -halfpixel.y) * radius) * 2.0; + + gl_FragColor = sum / 12.0; +} -- cgit v1.2.3