From 782260833e551dc02a2df2e2ad2a266e7bb51f38 Mon Sep 17 00:00:00 2001 From: Daniele Pintore Date: Wed, 4 Dec 2024 22:03:43 +0100 Subject: [PATCH] Add grayscale filter --- .config/hypr/hyprland.conf | 2 ++ .config/hypr/shaders/grayscale.frag | 33 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 .config/hypr/shaders/grayscale.frag diff --git a/.config/hypr/hyprland.conf b/.config/hypr/hyprland.conf index c050e4a..ecaf517 100644 --- a/.config/hypr/hyprland.conf +++ b/.config/hypr/hyprland.conf @@ -69,6 +69,8 @@ general { decoration { # See https://wiki.hyprland.org/Configuring/Variables/ for more + screen_shader = /home/daniele/.config/hypr/shaders/grayscale.frag + rounding = 5 blur { diff --git a/.config/hypr/shaders/grayscale.frag b/.config/hypr/shaders/grayscale.frag new file mode 100644 index 0000000..776c25c --- /dev/null +++ b/.config/hypr/shaders/grayscale.frag @@ -0,0 +1,33 @@ +// +// Example blue light filter shader. +// + +//precision mediump float; +//varying vec2 v_texcoord; +//uniform sampler2D tex; +// +//void main() { +// +// vec4 pixColor = texture2D(tex, v_texcoord); +// +// pixColor[2] *= 0.; +// +// gl_FragColor = pixColor; +//} +// Example grayscale shader. + +precision mediump float; // Set the precision for floating-point calculations. +varying vec2 v_texcoord; // Varying texture coordinate passed from the vertex shader. +uniform sampler2D tex; // The texture sampler. + +void main() { + // Sample the texture at the given coordinates. + vec4 pixColor = texture2D(tex, v_texcoord); + + // Compute the grayscale value using standard luminance weights. + float gray = 0.299 * pixColor.r + 0.587 * pixColor.g + 0.114 * pixColor.b; + + // Set the fragment color to the grayscale value, keeping the original alpha. + gl_FragColor = vec4(vec3(gray), pixColor.a); +} +