Skip to content

Instantly share code, notes, and snippets.

@nemolize
Created February 20, 2022 17:03
Show Gist options
  • Save nemolize/dca4793422caf95ce3f1af4f8380d1c2 to your computer and use it in GitHub Desktop.
Save nemolize/dca4793422caf95ce3f1af4f8380d1c2 to your computer and use it in GitHub Desktop.
Gray scale window fragment GLSL shader works with Picom compositor
/* To get this shader working, Run picom like the following
picom --glx-fshader-win "$(cat ~/.config/picom/gs.glsl)"
NOTE: You need to set the backend to "glx" to get this working.
*/
uniform float opacity;
uniform bool invert_color;
uniform sampler2D tex;
void main() {
vec4 c = texture2D(tex, gl_TexCoord[0].xy);
float g = (c.r + c.g + c.b) / 3.0; // EDIT1: Average.
c = vec4(vec3(g), c.a); // EDIT2: Color.
if (invert_color)
c = vec4(vec3(c.a, c.a, c.a) - vec3(c), c.a);
c *= opacity;
gl_FragColor = c;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment