Photon Mapping
Paper #
@article{jensen1995photon,
title={Photon maps in bidirectional Monte Carlo ray tracing of complex objects},
author={Jensen, Henrik Wann and Christensen, Niels J{\o}rgen},
journal={Computers \& Graphics},
volume={19},
number={2},
pages={215--224},
year={1995},
publisher={Elsevier}
}
Idea #
- Shoot photons from all light sources into the scene and store their contribution in a photon map (or light map)
- Render the scene normally (e.g. with ray tracing) and use illumination data from the photon map as a radiance estimate, see Light Physics
When a photon hits a surface #
Never store photon in the map on perfect mirrors: #
The only way it could contribute to the image, is if it comes from the perfect angle for the camera to pick it up later when actually rendering the scene, and that is super unlikely.
Otherwise store photon and choose one of the 3 #
(similar as Path Tracing )
- Terminate photon (Absorbtion)
- Diffuse reflection
- Specular reflection
Have material properties: for probability of diffuse reflection
and
for probability of specular reflection.
(Energy conservation)
Generate random number between 0 and 1:
- If
then reflect diffusely
- if
then reflect specularily
- else terminate (absorbtion)
Probability of a reflection vs absorbtion #
Probability of a diffuse vs specular reflection #
Two-photon-maps approach #
-
Caustics Map:
- terminate on diffuse surface
- at least one specular bounce
- high number of photons
- [if known] shoot more photons at objects that should generate caustics
-
Global Photon Map:
- No preferences or ristrictions
- More coarse distribution
Implementation #
Photon struct #
The photon struct as it is stored in the light map
struct Photon {
f32 x, y, z; // position
f32 phi, theta; // incident dir
f32 r, g, b; // power per band
};
Energy of the emitted photon #
Distribute light energy equally
Using the photon map for backwards rendering #
Sample the Photons around the area of interest.
- Spherical is easiest but also will pick up wrong values
- Ellipsoid is better but can still be wrong
When collecting around a radius near a edge of the geometry, it can happen, that you get a lower sample density and it will look like less light hit there per area.
Preventing shooting rays out of the scene #
- Render the scene from the lights perspective into a cube map (storing only 1 or 0 for each rendered object)
- Only shoot into the directions where objects where hit in (1)
Further improve the radiance estimate #
- Use distance weighting, so photons further away have less influence.