A flare is the transform of the aperture

Glare gets authored. Somebody picks a number of points, a color, and a falloff, and tunes until it looks right. All three of those are derivable, and the derived version reads as a photograph while the authored one reads as a sticker.

The same point source. Left: an authored six-point star with one color and an exponential falloff. Right: the pattern a seven-bladed aperture actually produces.

Where the pattern comes from

Light passing through an aperture diffracts, and in the far field the intensity pattern is the squared magnitude of the Fourier transform of the aperture shape. That is the whole of it, and everything else here is a consequence.

A polygonal iris has straight edges, and a straight edge transforms into a streak perpendicular to itself. So the streaks come from the blades, and their count follows a rule worth memorising:

Which is why fourteen-point stars are so common in photographs and so rare in rendered images: seven blades is an ordinary lens design, and nobody authoring a flare by hand picks fourteen.

The falloff is not exponential

A diffraction streak falls off roughly as an inverse power of distance, not exponentially. That matters more than it sounds: an exponential dies quickly and gives a streak with a definite end, while an inverse power has a heavy tail that keeps going faintly across the frame.

Streaks that stop are the most reliable tell of an authored flare. Real ones fade out of visibility rather than ending.

Color is the strongest signal, and it is free

The diffraction angle is proportional to wavelength. Red light, around 660nm, is thrown further from the source than blue at 450nm, by a ratio of about 1.45. So a single streak is spectrally spread: blue near the source, through green, red at the tip.

float sr = pattern(q * (550.0/660.0));   // red reaches further
float sg = pattern(q);
float sb = pattern(q * (550.0/450.0));   // blue stays closer

Three evaluations at three scales. It is the cheapest thing on this page and it does more than anything else to make the result read as optics rather than as art, because the eye has seen it in every photograph of a streetlight it has ever looked at.

Why production uses an FFT anyway

The analytic form above works because a regular polygon has an analytic answer. Real apertures do not: they have blade curvature, manufacturing scratches, dust, an aperture that is not quite closed evenly. Those produce the specific asymmetries that make one lens's flare recognizable.

So the production pipeline photographs or draws the aperture, transforms it once offline, and ships the result as a texture that gets convolved with the bright parts of the frame. The FFT is a precomputation step, not a runtime one, and the runtime cost is a convolution that can be done in the frequency domain or approximated with a few separable passes.

The important part is that the aperture is an input. Change the drawing, get a different flare, with no tuning, and every flare in the game agrees with every other one because they came from the same lens.

Rules of thumb

  1. The flare is the transform of the aperture. Streak count, falloff and color all follow from it.
  2. Even blades give N streaks, odd blades give 2N, a circle gives rings and no streaks.
  3. Falloff is an inverse power with a heavy tail. Streaks that visibly end read as authored.
  4. Scale the pattern per channel by wavelength ratio. Blue near the source, red at the tip. Three lines, enormous payoff.
  5. Draw the aperture and transform it offline. Then the flare is data, not tuning, and every light in the game agrees.
  6. Asymmetry, scratches and dust are what make a specific lens recognizable, and they are exactly what the analytic form cannot give you.

All 61 notes How to use them Credits