diff options
Diffstat (limited to 'sway/desktop/shaders')
-rw-r--r-- | sway/desktop/shaders/meson.build | 4 | ||||
-rw-r--r-- | sway/desktop/shaders/quad_round_tl.frag | 14 | ||||
-rw-r--r-- | sway/desktop/shaders/quad_round_tr.frag | 14 | ||||
-rw-r--r-- | sway/desktop/shaders/tex_external.frag | 15 | ||||
-rw-r--r-- | sway/desktop/shaders/tex_rgba.frag | 17 | ||||
-rw-r--r-- | sway/desktop/shaders/tex_rgbx.frag | 15 |
6 files changed, 59 insertions, 20 deletions
diff --git a/sway/desktop/shaders/meson.build b/sway/desktop/shaders/meson.build index 8eb12079..661ccc35 100644 --- a/sway/desktop/shaders/meson.build +++ b/sway/desktop/shaders/meson.build @@ -3,8 +3,10 @@ embed = find_program('./embed.sh', native: true) shaders = [ 'quad.vert', 'quad.frag', - 'tex.vert', + 'quad_round_tl.frag', + 'quad_round_tr.frag', 'corner.frag', + 'tex.vert', 'tex_rgba.frag', 'tex_rgbx.frag', 'tex_external.frag', diff --git a/sway/desktop/shaders/quad_round_tl.frag b/sway/desktop/shaders/quad_round_tl.frag new file mode 100644 index 00000000..6fd0119c --- /dev/null +++ b/sway/desktop/shaders/quad_round_tl.frag @@ -0,0 +1,14 @@ +precision mediump float; +varying vec4 v_color; +varying vec2 v_texcoord; + +uniform vec2 size; +uniform vec2 position; +uniform float radius; + +void main() { + vec2 q = abs(gl_FragCoord.xy - position - size) - size + radius; + float distance = min(max(q.x,q.y),0.0) + length(max(q,0.0)) - radius; + float smoothedAlpha = 1.0 - smoothstep(-1.0, 0.5, distance); + gl_FragColor = mix(vec4(0), v_color, smoothedAlpha); +} diff --git a/sway/desktop/shaders/quad_round_tr.frag b/sway/desktop/shaders/quad_round_tr.frag new file mode 100644 index 00000000..ff580045 --- /dev/null +++ b/sway/desktop/shaders/quad_round_tr.frag @@ -0,0 +1,14 @@ +precision mediump float; +varying vec4 v_color; +varying vec2 v_texcoord; + +uniform vec2 size; +uniform vec2 position; +uniform float radius; + +void main() { + vec2 q = abs(gl_FragCoord.xy - position - vec2(0, size.y)) - size + radius; + float distance = min(max(q.x,q.y),0.0) + length(max(q,0.0)) - radius; + float smoothedAlpha = 1.0 - smoothstep(-1.0, 0.5, distance); + gl_FragColor = mix(vec4(0), v_color, smoothedAlpha); +} diff --git a/sway/desktop/shaders/tex_external.frag b/sway/desktop/shaders/tex_external.frag index 404688c2..0703a05f 100644 --- a/sway/desktop/shaders/tex_external.frag +++ b/sway/desktop/shaders/tex_external.frag @@ -8,13 +8,16 @@ uniform float alpha; uniform vec2 size; uniform vec2 position; uniform float radius; +uniform bool has_titlebar; 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); - } + if (!has_titlebar || gl_FragCoord.y - position.y > radius) { + vec2 corner_distance = min(gl_FragCoord.xy - position, size + position - 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); + } + } } diff --git a/sway/desktop/shaders/tex_rgba.frag b/sway/desktop/shaders/tex_rgba.frag index 1886fab4..95f58987 100644 --- a/sway/desktop/shaders/tex_rgba.frag +++ b/sway/desktop/shaders/tex_rgba.frag @@ -6,13 +6,16 @@ uniform float alpha; uniform vec2 size; uniform vec2 position; uniform float radius; +uniform bool has_titlebar; void main() { - gl_FragColor = texture2D(tex, v_texcoord) * alpha; - vec2 corner_distance = min(gl_FragCoord.xy - position, size + position - 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); - } + gl_FragColor = texture2D(tex, v_texcoord) * alpha; + if (!has_titlebar || gl_FragCoord.y - position.y > radius) { + vec2 corner_distance = min(gl_FragCoord.xy - position, size + position - 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); + } + } } diff --git a/sway/desktop/shaders/tex_rgbx.frag b/sway/desktop/shaders/tex_rgbx.frag index cb6f1432..4a8b3756 100644 --- a/sway/desktop/shaders/tex_rgbx.frag +++ b/sway/desktop/shaders/tex_rgbx.frag @@ -6,13 +6,16 @@ uniform float alpha; uniform vec2 size; uniform vec2 position; uniform float radius; +uniform bool has_titlebar; void main() { gl_FragColor = vec4(texture2D(tex, v_texcoord).rgb, 1.0) * 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); - } + if (!has_titlebar || gl_FragCoord.y - position.y > radius) { + vec2 corner_distance = min(gl_FragCoord.xy - position, size + position - 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); + } + } } |