picom: browser transparency woOOOOOOOOO
This commit is contained in:
parent
fd9a0ce18f
commit
7f90afaabc
@ -20,7 +20,7 @@ animation-for-next-tag = "slide-in-center";
|
||||
enable-fading-next-tag = true;
|
||||
|
||||
# enable vsync
|
||||
vsync = true;
|
||||
vsync = false;
|
||||
|
||||
# shadow
|
||||
shadow = false;
|
||||
|
108
src/.config/picom/shaders/bloom.glsl
Normal file
108
src/.config/picom/shaders/bloom.glsl
Normal file
@ -0,0 +1,108 @@
|
||||
// https://github.com/ikz87/picom-shaders
|
||||
|
||||
#version 430
|
||||
|
||||
in vec2 texcoord;// texture coordinate of the fragment
|
||||
|
||||
uniform sampler2D tex;// texture of the window
|
||||
|
||||
uniform float cutoff = 0.55;// Brightness value that should be considered as a "bright" pixel
|
||||
|
||||
uniform float light_brightness = 1;// Scaling value for the brightness of the bloom effect
|
||||
|
||||
uniform float base_brightness = 1.2;// Scaling value for the brightness of the bright pixels
|
||||
|
||||
// Here are some kerneles you can use for the gaussian blur
|
||||
uniform float kernel1[5][5] = { { 0.003, 0.013, 0.022, 0.013, 0.003 },
|
||||
{ 0.013, 0.059, 0.097, 0.059, 0.013 },
|
||||
{ 0.022, 0.097, 0.159, 0.097, 0.022 },
|
||||
{ 0.013, 0.059, 0.097, 0.059, 0.013 },
|
||||
{ 0.003, 0.013, 0.022, 0.013, 0.003 } };
|
||||
|
||||
uniform float kernel2[7][7] = {
|
||||
{ 0.0051, 0.0094, 0.0135, 0.0153, 0.0135, 0.0094, 0.0051 },
|
||||
{ 0.0094, 0.0173, 0.0250, 0.0282, 0.0250, 0.0173, 0.0094 },
|
||||
{ 0.0135, 0.0250, 0.0361, 0.0407, 0.0361, 0.0250, 0.0135 },
|
||||
{ 0.0153, 0.0282, 0.0407, 0.0461, 0.0407, 0.0282, 0.0153 },
|
||||
{ 0.0135, 0.0250, 0.0361, 0.0407, 0.0361, 0.0250, 0.0135 },
|
||||
{ 0.0094, 0.0173, 0.0250, 0.0282, 0.0250, 0.0173, 0.0094 },
|
||||
{ 0.0051, 0.0094, 0.0135, 0.0153, 0.0135, 0.0094, 0.0051 },
|
||||
};
|
||||
|
||||
uniform float kernel3[15][15] = {
|
||||
{ 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0001, 0.0001, 0.0001, 0.0001, 0.0001, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000 },
|
||||
{ 0.0000, 0.0000, 0.0000, 0.0001, 0.0002, 0.0003, 0.0004, 0.0005, 0.0004, 0.0003, 0.0002, 0.0001, 0.0000, 0.0000, 0.0000 },
|
||||
{ 0.0000, 0.0000, 0.0001, 0.0003, 0.0006, 0.0011, 0.0016, 0.0018, 0.0016, 0.0011, 0.0006, 0.0003, 0.0001, 0.0000, 0.0000 },
|
||||
{ 0.0000, 0.0001, 0.0003, 0.0008, 0.0018, 0.0034, 0.0049, 0.0055, 0.0049, 0.0034, 0.0018, 0.0008, 0.0003, 0.0001, 0.0000 },
|
||||
{ 0.0000, 0.0002, 0.0006, 0.0018, 0.0043, 0.0079, 0.0115, 0.0130, 0.0115, 0.0079, 0.0043, 0.0018, 0.0006, 0.0002, 0.0000 },
|
||||
{ 0.0001, 0.0003, 0.0011, 0.0034, 0.0079, 0.0146, 0.0211, 0.0239, 0.0211, 0.0146, 0.0079, 0.0034, 0.0011, 0.0003, 0.0001 },
|
||||
{ 0.0001, 0.0004, 0.0016, 0.0049, 0.0115, 0.0211, 0.0305, 0.0345, 0.0305, 0.0211, 0.0115, 0.0049, 0.0016, 0.0004, 0.0001 },
|
||||
{ 0.0001, 0.0005, 0.0018, 0.0055, 0.0130, 0.0239, 0.0345, 0.0390, 0.0345, 0.0239, 0.0130, 0.0055, 0.0018, 0.0005, 0.0001 },
|
||||
{ 0.0001, 0.0004, 0.0016, 0.0049, 0.0115, 0.0211, 0.0305, 0.0345, 0.0305, 0.0211, 0.0115, 0.0049, 0.0016, 0.0004, 0.0001 },
|
||||
{ 0.0001, 0.0003, 0.0011, 0.0034, 0.0079, 0.0146, 0.0211, 0.0239, 0.0211, 0.0146, 0.0079, 0.0034, 0.0011, 0.0003, 0.0001 },
|
||||
{ 0.0000, 0.0002, 0.0006, 0.0018, 0.0043, 0.0079, 0.0115, 0.0130, 0.0115, 0.0079, 0.0043, 0.0018, 0.0006, 0.0002, 0.0000 },
|
||||
{ 0.0000, 0.0001, 0.0003, 0.0008, 0.0018, 0.0034, 0.0049, 0.0055, 0.0049, 0.0034, 0.0018, 0.0008, 0.0003, 0.0001, 0.0000 },
|
||||
{ 0.0000, 0.0000, 0.0001, 0.0003, 0.0006, 0.0011, 0.0016, 0.0018, 0.0016, 0.0011, 0.0006, 0.0003, 0.0001, 0.0000, 0.0000 },
|
||||
{ 0.0000, 0.0000, 0.0000, 0.0001, 0.0002, 0.0003, 0.0004, 0.0005, 0.0004, 0.0003, 0.0002, 0.0001, 0.0000, 0.0000, 0.0000 },
|
||||
{ 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0001, 0.0001, 0.0001, 0.0001, 0.0001, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000 }
|
||||
};
|
||||
|
||||
float blur_kernel[7][7] = kernel2;// Kernel to use for the gaussian blur
|
||||
|
||||
// Default window post-processing:
|
||||
// 1) invert color
|
||||
// 2) opacity / transparency
|
||||
// 3) max-brightness clamping
|
||||
// 4) rounded corners
|
||||
vec4 default_post_processing(vec4 c);
|
||||
|
||||
// Returns the brightness of a pixel
|
||||
float get_brightness(vec4 color)
|
||||
{
|
||||
return (color.x+color.y+color.z)/3;
|
||||
}
|
||||
|
||||
// Default window shader:
|
||||
// 1) fetch the specified pixel
|
||||
// 2) apply default post-processing
|
||||
vec4 window_shader() {
|
||||
// Variable where we will store the sum from the convolution with the kernel
|
||||
vec4 total = vec4(0);
|
||||
|
||||
// Radius of the kernel
|
||||
int radius = int(floor(blur_kernel[0].length()/2));
|
||||
|
||||
// Apply convolution
|
||||
for (int y = -radius; y <=radius; y++)
|
||||
{
|
||||
for (int x = -radius; x <=radius; x++)
|
||||
{
|
||||
// Fetch pixel
|
||||
vec4 c = texelFetch(tex, ivec2(texcoord.x+x, texcoord.y+y), 0);
|
||||
c = default_post_processing(c);
|
||||
|
||||
// If the brightness is below our cutoff, set the pixel
|
||||
// as an empty one
|
||||
if (get_brightness(c) < cutoff)
|
||||
{
|
||||
c = vec4(0);
|
||||
}
|
||||
|
||||
// Convolve and multiply by the light brightness
|
||||
c *= blur_kernel[x+radius][y+radius];
|
||||
c.xyz *= light_brightness;
|
||||
total.xyzw += c;
|
||||
}
|
||||
}
|
||||
|
||||
// Scale the brightness of the pixel with clamping
|
||||
vec4 c = texelFetch(tex, ivec2(texcoord), 0);
|
||||
if (get_brightness(c) >= cutoff)
|
||||
{
|
||||
c.xyz = min(c.xyz*base_brightness, 1);
|
||||
}
|
||||
|
||||
// Apply screen blending mode
|
||||
c.xyzw = 1-(1-total.xyzw)*(1-c.xyzw);
|
||||
return default_post_processing(c);
|
||||
}
|
63
src/.config/picom/shaders/chroma.glsl
Normal file
63
src/.config/picom/shaders/chroma.glsl
Normal file
@ -0,0 +1,63 @@
|
||||
// https://github.com/ikz87/picom-shaders
|
||||
|
||||
#version 330
|
||||
|
||||
|
||||
// Offsets in pixels for each color
|
||||
vec2 uvr = vec2(3,0);
|
||||
vec2 uvg = vec2(0,3);
|
||||
vec2 uvb = vec2(-3,0);
|
||||
|
||||
// Scaling of the effect. This makes the effect stronger
|
||||
// on pixels further away from the center of the window
|
||||
// and weaker on pixels close to it
|
||||
// Set as 0 to disable
|
||||
float scaling_factor = 1;
|
||||
|
||||
// Base strength of the effect. To be used along the scaling_factor
|
||||
// Tells how strong the effect is at the center
|
||||
float base_strength = 0;
|
||||
|
||||
in vec2 texcoord; // texture coordinate of the fragment
|
||||
|
||||
uniform sampler2D tex; // texture of the window
|
||||
ivec2 window_size = textureSize(tex, 0);
|
||||
ivec2 window_center = ivec2(window_size.x/2, window_size.y/2);
|
||||
|
||||
// Default window post-processing:
|
||||
// 1) invert color
|
||||
// 2) opacity / transparency
|
||||
// 3) max-brightness clamping
|
||||
// 4) rounded corners
|
||||
vec4 default_post_processing(vec4 c);
|
||||
|
||||
vec4 window_shader() {
|
||||
if (scaling_factor != 0)
|
||||
{
|
||||
// Calculate the scale for the current coordinates
|
||||
vec2 scale;
|
||||
scale.xy = base_strength+scaling_factor*((texcoord.xy - window_center.xy)/window_size.xy);
|
||||
|
||||
// Scale offsets
|
||||
uvr.xy *= scale.xy;
|
||||
uvg.xy *= scale.xy;
|
||||
uvb.xy *= scale.xy;
|
||||
}
|
||||
|
||||
// Calculate offset coords
|
||||
uvr += texcoord;
|
||||
uvg += texcoord;
|
||||
uvb += texcoord;
|
||||
|
||||
// Fetch colors using offset coords
|
||||
vec3 offset_color;
|
||||
offset_color.x = texelFetch(tex, ivec2(uvr), 0).x;
|
||||
offset_color.y = texelFetch(tex, ivec2(uvg), 0).y;
|
||||
offset_color.z = texelFetch(tex, ivec2(uvb), 0).z;
|
||||
|
||||
// Set the new color
|
||||
vec4 c;
|
||||
c.w = texelFetch(tex, ivec2(uvr), 0).w;
|
||||
c.xyz = offset_color;
|
||||
return default_post_processing(c);
|
||||
}
|
52
src/.config/picom/shaders/transparency.glsl
Normal file
52
src/.config/picom/shaders/transparency.glsl
Normal file
@ -0,0 +1,52 @@
|
||||
// https://github.com/ikz87/picom-shaders
|
||||
|
||||
#version 330
|
||||
// rgb value for the maximum transparency
|
||||
uniform vec3 median_color = vec3(0, 0, 0);
|
||||
// maximum derivation from the median_color of each color channel (rgb)
|
||||
uniform vec3 max_derivation = vec3(0.01);
|
||||
// e.g. (1,0,0)±(0.2,0.2,0.2) -> gradient from #c00 to #f00 to #f33 with #f00 being the least opaque
|
||||
// (0,0,0)±(0.25,0.25,0,25) -> gradient from #000 to #444 with #000 being at min_opacity
|
||||
// opacity for the median_color
|
||||
uniform float min_opacity = 0.1;
|
||||
// exponent for the gradient (e.g. 1 for linear, 2 for quadratic, etc)
|
||||
uniform int power = 2;
|
||||
// use mean for a different effect
|
||||
float get_float (vec3 c) {
|
||||
// maximum
|
||||
return max(max(c.r,c.g),c.b);
|
||||
// mean
|
||||
// return (v.r + v.g + v.b)/3;
|
||||
}
|
||||
// tweak the above variables and functions for your needs
|
||||
|
||||
// texture coordinate of the fragment
|
||||
in vec2 texcoord;
|
||||
// texture of the window
|
||||
uniform sampler2D tex;
|
||||
// Default window post-processing:
|
||||
// 1) invert color
|
||||
// 2) opacity / transparency
|
||||
// 3) max-brightness clamping
|
||||
// 4) rounded corners
|
||||
vec4 default_post_processing(vec4 c);
|
||||
|
||||
|
||||
// Default window shader:
|
||||
// 1) fetch the specified pixel
|
||||
// 2) apply default post-processing
|
||||
vec4 window_shader() {
|
||||
vec4 c = texelFetch(tex, ivec2(texcoord), 0);
|
||||
|
||||
// get the each colorchannels derivation from the median_color channels and normalize them
|
||||
vec3 normalized_derivation = abs(c.rgb - median_color)/max_derivation;
|
||||
// only add transparency, if the pixel is not already transparent
|
||||
if (c.a == 1 && get_float(normalized_derivation) < 1) {
|
||||
// apply the gradient curvature
|
||||
normalized_derivation = vec3(1)-pow(vec3(1)-normalized_derivation, vec3(power));
|
||||
// apply transparency to rgb and alpha, because glx uses premultiplied alpha
|
||||
c *= min_opacity + get_float(normalized_derivation) * (1-min_opacity);
|
||||
}
|
||||
|
||||
return default_post_processing( c );
|
||||
}
|
@ -8,7 +8,7 @@ if [ $SYSTEM_PROFILE = "MINIMAL" ]; then
|
||||
fi
|
||||
|
||||
if [ $SYSTEM_PROFILE = "DEFAULT" ]; then
|
||||
picom &
|
||||
picomstart.sh &
|
||||
fi
|
||||
battwatch.sh &
|
||||
xwallpaper --center .config/wall.png
|
||||
|
4
src/.local/bin/picomstart.sh
Executable file
4
src/.local/bin/picomstart.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
# misc opts so i don't have to use absolute path in picom config
|
||||
|
||||
picom --window-shader-fg-rule "$HOME/.config/picom/shaders/transparency.glsl:class_g = 'qutebrowser'"
|
Loading…
Reference in New Issue
Block a user