Vignette (Edge Darkening)

21 / 30
Use distance to center and smoothstep() to darken edges.

This is the Module 3 capstone. Combine distance from center with smoothstep to darken the edges — that's a vignette.


The approach

  1. Compute each pixel's distance from the canvas center
  2. Greater distance means closer to the edges
  3. Use smoothstep to turn distance into a 0–1 mask: 1 at center (bright), 0 at edges (dark)
  • d < 0.25: v = 1 (center, fully bright)
  • d > 0.6: v = 0 (corners, fully dark)
  • in between: smooth transition

Using the mask to mix colors


Exercise

The exercise has v = 1.0 (all bright, no vignette). Use 1.0 - smoothstep(0.25, 0.6, d) to compute the vignette mask v.

Answer Breakdown

smoothstep(0.25, 0.6, d) starts rising at d=0.25 and reaches 1 at d=0.6. The 1.0 - inverts: bright at center, dark at edges.

  • Smaller 0.25 → vignette starts closer to center
  • Smaller 0.6 → narrower transition, harder edge
  • Larger 0.6 (e.g. 1.0) → softer, gentler vignette

GLSL Code Editor

Correct Code Preview

Current Code Preview