Monte Carlo Sampling and Noise
Fire up a path tracer, let it throw a single ray-bundle at each pixel, and the first frame looks like
a photograph buried under television static — a grainy, speckled mess. Let it keep
going and the grain slowly melts away until the image is clean. What you are watching is
Monte Carlo integration at work: the renderer is estimating the colour of
every pixel by averaging random light paths, and the graininess is the estimator's error, called
variance, quietly shrinking.
This page explains why physically-based rendering is noisy in the first place, exactly how fast that
noise fades (spoiler: painfully — as 1/\sqrt{N}), and the clever
variance-reduction tricks — importance sampling, stratification, quasi-Monte Carlo,
and multiple importance sampling — that are what actually make a path tracer usable, far more than
just firing more rays. It builds directly on the
rendering equation and path tracing,
and leads into
denoising,
which cleans up the noise that no amount of sampling can economically remove.
The one idea: an integral is an average
The colour arriving at a pixel is an integral — a sum over every direction light
could have come from, weighted by how the surface reflects it. There is no formula for that integral
in a real scene; it depends on the whole world of geometry and lights. Monte Carlo integration turns
the integral into something we can compute: a random average.
- To estimate I = \int_\Omega f(x)\,dx, draw samples
X_1,\dots,X_N independently from a probability density
p(x), and average the values f/p:
\hat I_N = \frac{1}{N}\sum_{i=1}^{N}\frac{f(X_i)}{p(X_i)}.
- The estimator is unbiased: its expected value is exactly the true integral,
\mathbb{E}[\hat I_N] = I, for any density
p that is nonzero wherever f is. It is right
on average, even from one sample.
- Dividing by p(X_i) is the crucial correction: samples drawn from
regions we visit often (large p) are down-weighted, so no region gets
double-counted.
Applied to rendering, each random light path traced from the camera into the scene is
one sample X_i; the light it carries back, divided by the probability of
having chosen that path, is one term f(X_i)/p(X_i); and the
pixel colour is the average of those terms. One sample is a wild guess. A thousand
samples average out into a picture.
Why it is noisy: variance and the 1/\sqrt{N} wall
Each single-sample estimate f(X_i)/p(X_i) scatters around the true answer.
The spread of that scatter is the variance \sigma^2.
Averaging N independent samples shrinks the variance of the average by a
factor of N:
\operatorname{Var}[\hat I_N] = \frac{\sigma^2}{N}, \qquad \text{so the noise (standard error)} \quad \sqrt{\operatorname{Var}[\hat I_N]} = \frac{\sigma}{\sqrt{N}}.
The visible grain in the image is that standard error, and it falls only as
1/\sqrt{N}. This is the central, brutal fact of path tracing: to
halve the noise you must take four times as many samples; to make
the image ten times cleaner costs a hundred times the rays. Brute force runs into a wall of
diminishing returns almost immediately — the last bit of grain is fantastically expensive to remove by
counting alone.
A deterministic grid (quadrature) beats Monte Carlo handily in one or two dimensions. But a single
light path bounces many times, and each bounce adds two dimensions to the integral — a path of
b bounces lives in a space of dimension \sim 2b.
Grid methods suffer the curse of dimensionality: a grid with
k points per axis needs k^{d} points in
d dimensions — hopeless past a handful. Monte Carlo's
1/\sqrt{N} error, remarkably, does not depend on the dimension at
all. Slow but dimension-proof beats fast but dimension-cursed once the integral is high-dimensional,
which every real light-transport integral is.
Seeing the wall: error versus sample count
Here is the whole tragedy in one plot. The curve is the Monte Carlo error
\sigma/\sqrt{N} (with \sigma=1) as a function of
the number of samples N. Drag N and watch the
marker: early on, each extra sample buys a big drop in noise; but the curve flattens fast, and past a
few hundred samples you are pouring rays in for almost no visible gain. The faint straight line is a
hypothetical 1/N decay — what a good
quasi-Monte Carlo sequence can approach, and why it is worth the trouble.
The gap between the two curves is exactly the prize that variance reduction chases. You cannot change
the 1/\sqrt{N} law for plain random sampling, but you can shrink
the constant \sigma in front of it — often by orders of magnitude — and you
can switch to samples that decorrelate the error toward 1/N. That is what
the rest of the page is about.
Worked example: shrinking \sigma with importance sampling
Forget rendering for a moment and estimate a concrete integral,
I = \int_0^1 2x\,dx = 1.
We will estimate it two ways and compare the variance.
Uniform sampling. Draw X uniformly on
[0,1], so p(x)=1. Each sample contributes
f(X)/p(X) = 2X. The mean is
\int_0^1 2x\,dx = 1 (unbiased, good), and the variance of a single sample is
\sigma^2_{\text{unif}} = \int_0^1 (2x)^2 dx - 1^2 = \tfrac{4}{3} - 1 = \tfrac{1}{3} \approx 0.333.
The samples scatter a lot, because 2x is 0 at the
left and 2 at the right — most of the "value" hides near
x=1, where uniform sampling rarely looks.
Importance sampling. Now put the density where the integrand is large:
choose p(x) = 2x (a valid density — it integrates to
1 on [0,1]). Then every sample contributes
\frac{f(X)}{p(X)} = \frac{2X}{2X} = 1
— a constant! Every single sample returns exactly the right answer, so the variance is
\sigma^2_{\text{IS}} = 0. The estimator is perfect from one
sample.
When the sampling density is proportional to the integrand,
p(x) \propto f(x), the ratio f/p is constant and
the variance collapses to zero. We can never quite reach this ideal (if we knew
f exactly we would not need to integrate it), but the closer
p matches the shape of f, the lower the
variance. Importance sampling is the art of guessing that shape.
In a renderer we do not know f — it is the full light transport — but we
know its factors: the BRDF has a bright specular lobe, and the light sources are where the
energy comes from. So we sample directions towards the light and
along the BRDF lobe instead of uniformly over the hemisphere. Each path then carries
more weight and less scatter, and the same picture emerges in a fraction of the samples.
The variance-reduction toolbox
Practical path tracers stack several tricks, each attacking the noise from a different angle.
| Technique | Idea | What it buys |
| Importance sampling |
Draw samples where the integrand is large — sample the BRDF lobe and the light sources, not
the whole hemisphere uniformly. |
Shrinks \sigma dramatically; the closer p
matches f, the lower the variance. |
| Stratification (jittered sampling) |
Split the domain into cells and put one jittered sample in each, so samples cannot clump or
leave gaps. |
Removes the clumping component of variance; cheap and always helpful. |
| Quasi-Monte Carlo |
Replace random points with a low-discrepancy sequence (Halton, Sobol) that
fills space more evenly than randomness ever does. |
Error approaches \sim 1/N instead of
1/\sqrt{N} — a different, faster law. |
| Multiple importance sampling (MIS) |
Combine two samplers (BRDF sampling and light sampling) with a clever weight so whichever one
is better for this path dominates. |
Robust across shiny and matte surfaces, small and large lights — no single
sampler wins everywhere. |
Consider a glossy floor lit by a large area light — the classic
Monte Carlo
torture test. If you only sample the light, a near-mirror floor is a disaster: the
light directions almost never line up with the tight specular lobe, so nearly every sample is
wasted. If you only sample the BRDF, a rough floor under a tiny light is a
disaster: the fuzzy lobe rarely hits the small bright source. MIS, invented by Eric
Veach in his 1997 thesis, weights the two estimators so that for each surface roughness the
appropriate sampler carries the estimate — the shiny highlight comes out clean and the soft
diffuse shading comes out clean, in the same render. It is the single technique that made
general path tracing production-viable.
Why some scenes stay stubbornly noisy
Even with the whole toolbox, a few light-transport effects fight back. Caustics —
the bright ripples where light focuses through glass or off water — arrive along rare, tightly-focused
paths that unidirectional sampling almost never finds, so they stay speckled for a very long time.
Small, intense lights (a bare bulb, the sun through a keyhole) concentrate enormous
energy into a tiny solid angle: miss it and you get black, hit it and you get a blinding
firefly — a single pixel spiking far above its neighbours because one sample had a
huge f/p. High variance is firefly pixels.
These are exactly the cases where throwing more samples is uneconomical, and where the next lesson
picks up: rather than integrate the noise away, we
denoise
— use a smart filter (often a neural one) to reconstruct a clean image from a noisy, low-sample render,
trading a little bias for a huge saving in rays.
The most expensive mistake in rendering is trying to beat noise with sample count alone. Because noise
falls only as 1/\sqrt{N}, quadrupling your render time
merely halves the grain — a terrible trade. What makes path tracing practical is not
more rays but better rays: importance sampling (matching
p to the integrand) and MIS can cut the variance constant
by orders of magnitude for free, which is worth thousands of extra samples. And beware the opposite
temptation: biased tricks (clamping fireflies, capping path length, some denoisers)
do kill noise, but they trade it for systematic error — the image converges
to the wrong answer, not just a noisy one. Unbiased estimators are noisy but honest; biased
ones are smooth but subtly lie. Know which you are using.