diff options
| author | krolxon <krolyxon@tutanota.com> | 2026-01-11 19:18:06 +0530 |
|---|---|---|
| committer | krolxon <krolyxon@tutanota.com> | 2026-01-11 19:18:06 +0530 |
| commit | ea8f17368def0b581efcc332d057c0a034d4da9b (patch) | |
| tree | 5fd0bfd6627d34b93090d79628bdd87793e9f715 /.config/hypr/shaders/10_grayscale.glsl | |
| parent | 4c31a041975718cc2fb933012a303cf457475ce7 (diff) | |
add shader script and keybinds
Diffstat (limited to '.config/hypr/shaders/10_grayscale.glsl')
| -rwxr-xr-x | .config/hypr/shaders/10_grayscale.glsl | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/.config/hypr/shaders/10_grayscale.glsl b/.config/hypr/shaders/10_grayscale.glsl new file mode 100755 index 0000000..f80900e --- /dev/null +++ b/.config/hypr/shaders/10_grayscale.glsl @@ -0,0 +1,40 @@ +#version 300 es +// Grayscale Shader for Hyprland - OPTIMIZED +// Added: Optional gamma-correct conversion for accurate luminance + +precision highp float; + +in vec2 v_texcoord; +uniform sampler2D tex; +out vec4 fragColor; + +// Rec. 709 Luma coefficients (sRGB/HDTV standard) +const vec3 LUMA_709 = vec3(0.2126, 0.7152, 0.0722); + +// Set to true for gamma-correct grayscale (more accurate but slightly slower) +const bool GAMMA_CORRECT = false; + +// sRGB gamma functions +float toLinear(float c) { + return c <= 0.04045 ? c / 12.92 : pow((c + 0.055) / 1.055, 2.4); +} +float toSRGB(float c) { + return c <= 0.0031308 ? c * 12.92 : 1.055 * pow(c, 1.0/2.4) - 0.055; +} + +void main() { + vec4 pixColor = texture(tex, v_texcoord); + + float gray; + if (GAMMA_CORRECT) { + // Convert to linear space, compute luminance, convert back + vec3 linear = vec3(toLinear(pixColor.r), toLinear(pixColor.g), toLinear(pixColor.b)); + float luminance = dot(linear, LUMA_709); + gray = toSRGB(luminance); + } else { + // Fast path: direct computation in gamma space + gray = dot(pixColor.rgb, LUMA_709); + } + + fragColor = vec4(vec3(gray), pixColor.a); +} |
