Krolyxon
Commit e5e86b3

Branches

Refs →

aurora.confighyprshaders14_vibrance.glsl

37 lines · 1.1 KB · GLSL

1#version 300 es
2// Vignette Shader - OPTIMIZED
3// Fixes: Aspect ratio correction for circular vignette, safe smoothstep bounds
4
5precision highp float;
6
7in vec2 v_texcoord;
8uniform sampler2D tex;
9out vec4 fragColor;
10
11// --- CONFIGURATION ---
12const float RADIUS = 0.65;
13const float SOFTNESS = 0.45;
14const float STRENGTH = 0.5;
15// Set to your monitor's aspect ratio for circular vignette
16const float ASPECT_RATIO = 16.0 / 9.0;
17
18void main() {
19 vec4 color = texture(tex, v_texcoord);
20
21 // FIXED: Aspect-corrected distance for circular (not elliptical) vignette
22 vec2 centered = v_texcoord - 0.5;
23 centered.x *= ASPECT_RATIO;
24 float dist = length(centered);
25 // Normalize so corner distance is ~1.0 regardless of aspect ratio
26 dist /= length(vec2(ASPECT_RATIO * 0.5, 0.5));
27
28 // FIXED: Ensure smoothstep has valid bounds (edge1 > edge0)
29 float innerEdge = RADIUS;
30 float outerEdge = RADIUS + SOFTNESS;
31 float vignette = 1.0 - smoothstep(innerEdge, outerEdge, dist);
32
33 // Apply with strength control
34 color.rgb = mix(color.rgb, color.rgb * vignette, STRENGTH);
35
36 fragColor = color;
37}