Krolyxon
Commit 129bacc

Branches

Refs →

aurora.confighyprshaders16_vignette.glsl

37 lines · 1.3 KB · GLSL

1#version 300 es
2// Vignette Shader for Hyprland
3// Description: Darkens the edges of the screen to draw focus to the center.
4// Uses smoothstep for a high-quality, organic falloff.
5
6precision highp float;
7
8in vec2 v_texcoord;
9uniform sampler2D tex;
10out vec4 fragColor;
11
12// --- CONFIGURATION ---
13// The radius where the darkening begins (0.0 is center, 0.8 is near corners)
14const float RADIUS = 0.85;
15// How soft the transition is (higher = smoother gradient)
16const float SOFTNESS = 0.85;
17// The strength of the darkness (0.0 = no vignette, 1.0 = pitch black corners)
18const float STRENGTH = 0.8;
19
20void main() {
21 // 1. Sample the original screen color
22 vec4 color = texture(tex, v_texcoord);
23
24 // 2. Calculate distance from center (0.5, 0.5)
25 float dist = distance(v_texcoord, vec2(0.5));
26
27 // 3. Calculate vignette factor using smoothstep for high-quality falloff
28 // We invert the smoothstep range so 1.0 is center and 0.0 is edges
29 float vignette = smoothstep(RADIUS, RADIUS - SOFTNESS, dist);
30
31 // 4. Apply the vignette strength
32 // Mix between the original color and the darkened version
33 // This allows us to control intensity without changing the geometry of the falloff
34 color.rgb = mix(color.rgb, color.rgb * vignette, STRENGTH);
35
36 fragColor = color;
37}