aboutsummaryrefslogtreecommitdiff
path: root/.config/hypr/shaders/vibrance.glsl
blob: 7b38230a40845ba4c8c8ae5ea2f075eb2a43651a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#version 300 es
// Saturation & Contrast Shader for Hyprland
// Description: Allows fine-tuning of screen vibrancy and dynamic range.
// Efficiently applies saturation followed by contrast.

precision highp float;

in vec2 v_texcoord;
uniform sampler2D tex;
out vec4 fragColor;

// --- CONFIGURATION ---
// 0.0 = Grayscale, 1.0 = Normal, 1.5 = Vibrant, 2.0 = Deep Fried
const float SATURATION = 3.0;

// 1.0 = Normal, 1.2 = High Contrast, 0.8 = Low Contrast (Faded)
const float CONTRAST = 1.0;
// ---------------------

// Rec. 709 Luma coefficients for accurate saturation calculations
const vec3 luma = vec3(0.2126, 0.7152, 0.0722);

void main() {
    // 1. Sample texture
    vec4 color = texture(tex, v_texcoord);
    
    // 2. Apply Saturation
    // Calculate the grayscale value (luminance)
    float gray = dot(color.rgb, luma);
    // Interpolate between grayscale and original color
    vec3 satColor = mix(vec3(gray), color.rgb, SATURATION);
    
    // 3. Apply Contrast
    // We shift color values so 0.5 is the "pivot" point.
    // Values > 0.5 get pushed up, values < 0.5 get pushed down.
    vec3 finalColor = (satColor - 0.5) * CONTRAST + 0.5;
    
    // 4. Output
    fragColor = vec4(finalColor, color.a);
}