summaryrefslogtreecommitdiff
path: root/sway/desktop/shaders/tex_external.frag
diff options
context:
space:
mode:
Diffstat (limited to 'sway/desktop/shaders/tex_external.frag')
-rw-r--r--sway/desktop/shaders/tex_external.frag20
1 files changed, 20 insertions, 0 deletions
diff --git a/sway/desktop/shaders/tex_external.frag b/sway/desktop/shaders/tex_external.frag
new file mode 100644
index 00000000..404688c2
--- /dev/null
+++ b/sway/desktop/shaders/tex_external.frag
@@ -0,0 +1,20 @@
+#extension GL_OES_EGL_image_external : require
+
+precision mediump float;
+varying vec2 v_texcoord;
+uniform samplerExternalOES texture0;
+uniform float alpha;
+
+uniform vec2 size;
+uniform vec2 position;
+uniform float radius;
+
+void main() {
+ gl_FragColor = texture2D(texture0, v_texcoord) * alpha;
+ vec2 corner_distance = min(gl_FragCoord.xy - position, position + size - gl_FragCoord.xy);
+ if (max(corner_distance.x, corner_distance.y) < radius) {
+ float d = radius - distance(corner_distance, vec2(radius));
+ float smooth = smoothstep(-1.0f, 0.5f, d);
+ gl_FragColor = mix(vec4(0), gl_FragColor, smooth);
+ }
+}