mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-21 09:35:40 +02:00
picom: tentative to use a shader for rounded borders
This does not work with i3 border.
This commit is contained in:
parent
cbd4a999d9
commit
ad25a8d915
2 changed files with 45 additions and 0 deletions
|
@ -67,3 +67,6 @@ shadow-exclude = [
|
|||
"name = 'Screen Sharing Tracker'" # Jitsi
|
||||
];
|
||||
fade-exclude = [ ];
|
||||
|
||||
corner-radius = @SHADOW_RADIUS@
|
||||
window-shader-fg = "rounded-borders.glsl"
|
||||
|
|
42
dotfiles/rounded-borders.glsl
Normal file
42
dotfiles/rounded-borders.glsl
Normal file
|
@ -0,0 +1,42 @@
|
|||
#version 330
|
||||
|
||||
in vec2 texcoord;
|
||||
uniform sampler2D tex;
|
||||
uniform float corner_radius;
|
||||
|
||||
vec4 default_post_processing(vec4 c);
|
||||
|
||||
vec4 add_rounded_corners(
|
||||
vec4 win_color,
|
||||
vec2 tex_coord,
|
||||
vec2 tex_size,
|
||||
float radius,
|
||||
float thickness)
|
||||
{
|
||||
// If we're far from corners, we just pass window texels through
|
||||
vec2 corner_distance = min(abs(tex_coord), abs(tex_size - 1 - tex_coord));
|
||||
if (any(greaterThan(corner_distance, vec2(radius))))
|
||||
return win_color;
|
||||
|
||||
// Distance from the closest arc center
|
||||
vec2 center_distance = min(
|
||||
abs(vec2(radius) - tex_coord),
|
||||
abs(vec2(tex_size - radius) - tex_coord));
|
||||
|
||||
// Do some simple anti-aliasing
|
||||
float inner_radius = radius - thickness;
|
||||
float feather = 1 / inner_radius;
|
||||
float r = length(center_distance) / inner_radius;
|
||||
float blend = smoothstep(1, 1 + feather, r);
|
||||
|
||||
vec4 border_color = texture2D(tex, vec2(0), 0);
|
||||
return blend * border_color + (1.0 - blend) * win_color;
|
||||
}
|
||||
|
||||
vec4 window_shader()
|
||||
{
|
||||
vec2 tex_size = textureSize(tex, 0);
|
||||
vec4 c = texture2D(tex, texcoord / tex_size, 0);
|
||||
vec4 with_corners = add_rounded_corners(c, texcoord, tex_size, corner_radius, 6);
|
||||
return default_post_processing(with_corners);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue