summaryrefslogtreecommitdiff
path: root/sway/desktop/fx_renderer/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'sway/desktop/fx_renderer/shaders')
-rw-r--r--sway/desktop/fx_renderer/shaders/blur1.frag18
-rw-r--r--sway/desktop/fx_renderer/shaders/blur2.frag22
-rw-r--r--sway/desktop/fx_renderer/shaders/meson.build2
3 files changed, 42 insertions, 0 deletions
diff --git a/sway/desktop/fx_renderer/shaders/blur1.frag b/sway/desktop/fx_renderer/shaders/blur1.frag
new file mode 100644
index 00000000..e7cb1be8
--- /dev/null
+++ b/sway/desktop/fx_renderer/shaders/blur1.frag
@@ -0,0 +1,18 @@
+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) * 4.0;
+ sum += texture2D(tex, uv - halfpixel.xy * radius);
+ sum += texture2D(tex, uv + halfpixel.xy * radius);
+ sum += texture2D(tex, uv + vec2(halfpixel.x, -halfpixel.y) * radius);
+ sum += texture2D(tex, uv - vec2(halfpixel.x, -halfpixel.y) * radius);
+
+ gl_FragColor = sum / 8.0;
+}
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;
+}
diff --git a/sway/desktop/fx_renderer/shaders/meson.build b/sway/desktop/fx_renderer/shaders/meson.build
index 6c0dd1d3..83119963 100644
--- a/sway/desktop/fx_renderer/shaders/meson.build
+++ b/sway/desktop/fx_renderer/shaders/meson.build
@@ -1,6 +1,8 @@
embed = find_program('./embed.sh', native: true)
shaders = [
+ 'blur1.frag',
+ 'blur2.frag',
'box_shadow.frag',
'common.vert',
'corner.frag',