aboutsummaryrefslogtreecommitdiff
path: root/.config/hypr/shaders/14_vibrance.glsl
blob: e0a8350fd640ff2397c8e307b04483c9e2d7b387 (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
#version 300 es
// Vignette Shader - OPTIMIZED  
// Fixes: Aspect ratio correction for circular vignette, safe smoothstep bounds

precision highp float;

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

// --- CONFIGURATION ---
const float RADIUS = 0.65;
const float SOFTNESS = 0.45;
const float STRENGTH = 0.5;
// Set to your monitor's aspect ratio for circular vignette
const float ASPECT_RATIO = 16.0 / 9.0;

void main() {
    vec4 color = texture(tex, v_texcoord);
    
    // FIXED: Aspect-corrected distance for circular (not elliptical) vignette
    vec2 centered = v_texcoord - 0.5;
    centered.x *= ASPECT_RATIO;
    float dist = length(centered);
    // Normalize so corner distance is ~1.0 regardless of aspect ratio
    dist /= length(vec2(ASPECT_RATIO * 0.5, 0.5));
    
    // FIXED: Ensure smoothstep has valid bounds (edge1 > edge0)
    float innerEdge = RADIUS;
    float outerEdge = RADIUS + SOFTNESS;
    float vignette = 1.0 - smoothstep(innerEdge, outerEdge, dist);
    
    // Apply with strength control
    color.rgb = mix(color.rgb, color.rgb * vignette, STRENGTH);
    
    fragColor = color;
}