artween.com

Middle Grey — what a rendered image is actually doing

Entry 05 · Light Transport

Importance

Sampling randomly is honest, but stupid. Sending rays toward the sources — and the BRDFs that matter — is the same integral, solved faster.

Entry
05
Section
01 Light Transport
By
Ines Waldram
Read
3 min
Multiple thin red laser beams fan out diagonally against a dark background
Plate 01 · Light TransportSending rays where the light actually is rather than uniformly. The single biggest win available.Photo: Тимур Керимов / Pexels

By Ines Waldram · Light Transport · 3 min read

The problem with equal treatment

A path tracer integrates light over a hemisphere. The naive version samples that hemisphere uniformly: every direction gets an equal ticket in the lottery. That is statistically correct — the estimator is unbiased — but it is spectacularly wasteful when a small portion of the hemisphere actually carries light and the rest is dark sky.

Imagine a scene lit by a single small area light subtending an angle of two degrees. A uniform hemisphere sampler fires rays in every direction. Nearly all of them miss the light entirely, return zero, and contribute nothing but noise. The handful that land on the luminaire drive all the variance in the estimate. The estimator will converge, eventually, but you will hit your deadline before it does.

This is not a renderer deficiency; it is the geometry of the problem. The integrand is almost everywhere zero and sharply peaked over the source. Noise is a budget: every sample that misses that peak is money spent on silence.

What importance sampling does

Importance sampling does not change what you are calculating. It changes how you draw samples to calculate it. The core identity is simple: if you concentrate samples in the directions where the integrand is large, and weight each sample by the inverse of the probability with which you drew it, the expected value is unchanged and the variance falls — often dramatically.

In practice there are two places this matters most, and a renderer uses both at once.

Lighting: instead of sampling the hemisphere blindly, you query the light sources directly. You pick a point on a visible luminaire — weighted by emitted power and inverse-square distance — and trace a shadow ray to it. For a small, bright source, this is the single biggest variance reduction available in the whole pipeline. The number of samples required to reach a given noise level can drop by orders of magnitude compared with cosine-weighted hemisphere sampling alone.

A neutral grey card held against a plain background
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.

The BRDF: the reflectance function of a surface is also a distribution. A perfectly specular mirror has all its weight in one direction; a rough metallic surface spreads it in a lobe. Drawing outgoing directions according to the BRDF's own shape — rather than uniformly over the hemisphere — concentrates samples where reflected energy actually goes. For glossy surfaces, this is essential; for nearly-Lambertian surfaces, the gain is modest but still real.

When both are active simultaneously, the renderer must decide how to combine them. Multiple importance sampling (MIS), developed by Eric Veach in his 1997 doctoral dissertation at Stanford, provides the answer: weight each technique by how good it was for this particular sample, using the power heuristic or the balance heuristic. A bright diffuse surface near a large area light is better served by lighting samples; a sharp specular highlight is better served by BRDF samples. MIS lets the renderer blend them without introducing bias, and without the renderer needing to know in advance which regime any given shading point falls into.

The naive version samples that hemisphere uniformly: every direction gets an equal ticket in the lottery.

Where importance sampling breaks down

Importance sampling is only as good as the model it samples from. If the model of the light distribution is wrong — because a luminaire is occluded, or because indirect light dominates over direct — you can draw perfectly importance-sampled direct rays and still converge slowly, because the real light is arriving from elsewhere.

This is why caustics remain expensive despite everything else working well: the path that matters passes through a transmissive surface and reconcentrates on a receiver, and no simple product-sampling scheme finds it efficiently. The importance you need to capture is the joint probability of the entire path, not the local one-bounce estimate.

The other failure mode is the firefly. When a sampled direction hits an unexpectedly bright emitter — one that the probability model assigned very low weight — the inverse-probability correction amplifies it into a spike. Importance sampling and the firefly problem are the same coin: good sampling suppresses both tails, but a single bad draw from a poorly modelled distribution can overwhelm a pass. The technique reduces variance on average; it does not eliminate outliers from imperfect models.

None of that diminishes the principle. For the common case — a bounded scene, identified light sources, surfaces whose BRDF is known — importance sampling is the reason a production render is not taking a week per frame.

Specimen · Light Transport1600 × 1000
Photography studio with light stands, white backdrop, and a small table holding spheres and bottles
Where the light goes, and how many bounces you pay for.