Open quantenzitrone opened 1 year ago
fancy pants transparency, adds transparency depending on the color/brightness/etc of the window
I wanted that feature so bad, so I wrote a little shader, so I'll put it here, so other people could find it:
#version 330
in vec2 texcoord;
uniform sampler2D tex;
const float min_alpha = 0.8;
const float upper_bound = 0.18;
vec4 default_post_processing(vec4 c);
vec4 window_shader() {
vec2 texsize = textureSize(tex, 0);
vec4 color = texture2D(tex, texcoord / texsize, 0);
float pixel_brightness = (color.r + color.g + color.b) / 3;
color.a = mix(min_alpha, 1, pixel_brightness / upper_bound);
return default_post_processing(color);
}
the transparency depends on the "brightness" of the pixel (average of r,g,b)
it then interpolates between min_alpha
and 1 to set the alpha of the pixel based on it's brightness
upper_bound
is value of brightness that should be of alpha 1.0, anything higher too
and a little caveat - I need to set a black background with feh (just a 1 black pixel image) before I set wallpaper with anything else (like wal, xwinwrap+mpv, nitrogen etc). xsetroot -solid "#000000" does not work, and feh --bg-fill
leaks some buffer with bits of your screen.
feh --bg-max "$HOME/.bins/black_dot.png"
HOWEVER - this really doesn't play nicely with content like videos or photos. A lot of dark areas on them will leak your wallpaper
i made a better version of your shader a while ago here: https://github.com/ikz87/picom-shaders there are also some other nice shaders in there
i made a better version of your shader a while ago here: https://github.com/ikz87/picom-shaders there are also some other nice shaders in there
Great work! But it's overkill for what I was trying to achieve. Other shaders are also nice, However a lot of them (especially in 3d section) are segfaulting in picom
I think #726 (loading custom textures) might be able to be reclassed as a subset of "more interface for shaders."
However a lot of them (especially in 3d section) are segfaulting in picom
do you have a nvidia gpu? some of them are indeed causing a segfault but for me the segfault happens somewhere in the nvidia's drivers so i don't think that we can do something about this.
do you have a nvidia gpu?
yeah, I do. I didn't realize that their drivers were this buggy, I thought bugs were more random and/or chaotic, but this seems to be stably reproducible.
Maybe we should file a bugreport on this one? I know that the scale of the problem isn't huge so they likely wouldn't care, but at least we would do our part?
Idk how to trace this on my machine tho
problem description
the current interface for the glsl shaders doesn't provide enough features using
window-shader-fg-rules
, we can use more interface, but for n shader effects depending on n window properties in a boolean way, we need 2^n shaders to apply the rules. for example:shader effect 1:
shader effect 2:
result: 4 shaders with a lot of redundancy:
proposed additions
uniform bool fullscreen;
uniform bool focused;
probably also any other bool, int or float property could be useful to some peopleby adding everything possible, the number of needed shaders could be reduced to a minimum
alternatives
adding functionality to pass any conditions as bool to shaders
or
be able to stack shaders (one shader per shader effect)
or
using
window-shader-fg-rules
disadvantages see problem description