Shader Learn

12 From picture to recipe

Edges: one distance, five ways to draw it

Same shape; only the “distance → light” line changes: hard edge, antialiased, outline, glow, contours.

0.0020.04
ExerciseTune values0%

Make this neon glowing outline

Runs once per pixelDrag numbers, or edit the code

JS sidegl.uniform2f(uResolution, …, …)

d is the distance to the edge. step and smoothstep fill the shape; abs(d) makes both sides of the edge positive, so subtracting w gives an outline; w / abs(d) brightens near the edge, which is glow; cos(d / w) draws contour rings.

Try it

  • Switch between step and antialiased and compare the edges
  • Switch to glow and make w larger
  • Switch to contours: the lines follow the merged shape of both circles