Photon Mapping

Photon Mapping Fundamentals

Photon Mapping is currently one of the fastest algorithms available for simulating Global Illumination. It is a Monte-Carlo based technique, which computes a huge part of the global illumination solution by a rough but acceptable statistical estimation instead of the usual attempt to compute the most exact solution as possible. Another advantage of the Photon Mapping technique is that it uses the already available ray-tracing rendering engine although not exclusively for ray-tracing.

The Photon Mapping technique was developed by Henrik Wann Jensen and the first published papers discussing the technique appeared in 1995. For anyone interested in better understanding the technique, Jensen have published the book "Realistic Image Synthesis Using Photon Mapping".

Photon Mapping is a two-pass algorithm, which takes a mixed approach, and adds two very clever twists.

Shoot and store photons

In the first pass, photons are shot from the light into the scene. They are bounced around interacting with all the types of surfaces they encounter. The first twist is that instead of redoing those same computations over and over, a few thousand of time for each pixels, the photons are stored only once in a special data structure called a photon map for later reuse. The second twist is that instead of trying to completely fill the whole scene with billions of photons, a few thousands to a million photons are sparsely stored and the rest is statistically estimated from the density of the stored photons.

The Photon Map is not an image file as its name may imply but a hierarchical 3D spatial search acceleration structure called a kd-tree.

After all the photons have been stored in the map, a statistical estimate of the illumination at each photon is computed.

Gather illumination

In the second pass, direct illumination is computed just like regular Ray-Tracing but the indirect illumination, which comes from the walls and other objects around, is computed from querying the stored photons in the photon map. When rendering indirect illumination, the two passes use a Monte-Carlo estimation although, in some very particular cases, the second step could dispensed from the Monte-Carlo estimation. When rendering caustics, the second step renders the photon map directly and thus don't use the Monte-Carlo estimation.

When rendering indirect illumination, the second pass uses a Monte-Carlo estimation technique known as the final gathering because, at each pixel, several rays are shot from the first hit point into the environment. At each secondary hit, the photon map is queried in order to gather the illumination coming from the objects around in the environment.

The final gathering technique is not exclusive to photon mapping though. It is used in the majority of the multi-pass GI algorithms.

Photon mapping parameters.

Because the Photon Mapping technique uses two Monte-Carlo estimations, it is inherently much slower than the ray-tracing alone. But how much slower depends on the setting of the different parameters controlling the two passes of the algorithm, mainly parameters which controls the number of samples to use in the Monte-Carlo estimate. For the first pass, this means the number of photons in the scene and for the second pass, it means the number of Monte-Carlo samplings.

In addition, the statistical estimate of the illumination at each photon is performed with a density estimation. Here, the number of photon samples is the most important parameter that will affect the render time.

Roughly, the lower those parameters, the fastest the render and vice-versa. However, too low values will produce too rough estimates and thus too many artefacts in the render.

Next: The Monte-Carlo Estimation Technique. An overview of how the Monte-Carlo estimate is used in rendering algorithms.