artween.com

Middle Grey — what a rendered image is actually doing

Entry 07 · Sampling

Firefly

One absurdly bright sample in a dark region, and the clamp that hides it.

Entry
07
Section
02 Sampling
By
Marek Sowa
Read
2 min
Scattered colorful bokeh lights float against a dark background like glowing particles
Plate 01 · SamplingOne absurdly bright sample in a dark region, and the clamp that hides it.Photo: K / Pexels

By Marek Sowa · Sampling · 2 min read

What a firefly is

A firefly is a single sample whose estimated radiance is orders of magnitude higher than its neighbours. On screen it reads as a bright white or coloured speck — one pixel blazing in a dark region — and it persists stubbornly across frames unless you either add enough samples to drown it or reach for a clamp.

The physics behind it is legitimate. Monte Carlo integration is an estimator: each ray traces a path and returns a value that, averaged with thousands of others, converges on the correct answer. Most paths return unremarkable values. But occasionally a path finds a geometry configuration where the solid-angle weight, the BSDF evaluation and the light intensity all compound together — a specular surface at a grazing angle, a very small but very bright emitter, a lens-like caustic focus — and the estimator returns a value that is technically correct for that one path but wildly unrepresentative of the local neighbourhood. The variance is real; the renderer found a high-energy corridor that the surrounding samples missed.

What the clamp does, and what it costs

The standard fix is a firefly clamp (also called a sample clamp or indirect clamp): any per-sample radiance above a threshold is clamped to that threshold before being accumulated. It is fast, it is simple, and it removes the speck.

The cost is energy. Every clamped sample is a sample whose true value has been discarded and replaced with a smaller one. The image grows darker in the exact regions where the renderer found legitimate bright indirect paths — glossy interreflections, bright spots behind glass, the lit rim of a dark object. Clamp too aggressively and you are manufacturing a physically incorrect image; clamp too conservatively and the firefly survives. The threshold requires a judgment call about which error you can live with.

A better but more expensive answer is to let the path count grow until the high-energy samples are diluted by their neighbours — exactly what noise is a budget describes at the level of variance and sample cost. In practice, a combination of well-tuned importance sampling and a light clamp is the working compromise: importance sampling reduces the probability of finding extreme-weight paths in the first place, and the clamp handles the survivors. Neither alone is sufficient for a frame that has to ship.

A colour checker chart propped on a grey surface
On the tableEvery entry starts from something physical you could put on a table — a chrome ball, a grey card, a colour checker — and works outward to what the renderer does with it.
Specimen · Sampling1600 × 1000
A neutral grey card held against a plain background
Noise is a budget, not a bug.

More in Sampling

Every entry in this section is listed on the Sampling page, and all twenty-four sit in the full register.