Camera Vignette Shader

Edge of screen (All Sides) Rounded Vignette

Shader code
shader_type canvas_item;

// Stronger defaults
uniform float radius:    hint_range(0.0, 1.0) = 0.22;  // where darkening starts (smaller = more encroachment)
uniform float softness:  hint_range(0.0, 1.0) = 0.38;  // feather width toward center
uniform float intensity: hint_range(0.0, 3.0) = 2.00;  // overall darkness
uniform float contrast:  hint_range(0.5, 4.0) = 2.20;  // >1.0 sharpens falloff
uniform vec4 vignette_color: source_color = vec4(0.0, 0.0, 0.0, 1.0);

void fragment() {
    vec2 uv = SCREEN_UV;
    vec2 centered = uv - vec2(0.5);

    // Edge-driven shape (0 at center, 1 at edges):
    // Chebyshev distance = pushes from ALL edges uniformly
    float edge_box = max(abs(centered.x) * 2.0, abs(centered.y) * 2.0);

    // Blend a little radial in to avoid a "boxy" look (optional)
    float edge_radial = length(centered) * 2.0; // 0 center -> ~1 corners
    float shape = mix(edge_box, edge_radial, 0.25);

    // Darken from radius inward with feather = softness
    float v = smoothstep(radius, radius + softness, shape);
    v = pow(v, contrast);

    vec4 overlay = vignette_color;
    overlay.a = clamp(v * intensity, 0.0, 1.0);

    // Output just the vignette color/alpha (use on a full-screen ColorRect)
    COLOR = overlay;
}
Live Preview
Tags
Dark Edges., vignette
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments