In computer graphics, the term
photon mapping (also called photon tracing)
is a technique used to illuminate a 3D scene.
It is similar to radiosity in that it starts
out with the light sources in the scene, and
traces the light's absorptions and
interactions before it
reaches a low enough energy to be ignored.
Classic radiosity techniques, however, can not
be applied to scenes with specular lighting;
mirrors, glass objects, etc. (although some
tricks have been applied with some success).
Furthermore, regular
radiosity will only track the light by
projecting it from polygon based surfaces,
and will not work for some of the other types
of objects, such as spheres, toruses, and
other parametric surfaces.
Photon mapping to the rescue!
Algorithmically speaking,
photon mapping has some similarities
to ray tracing, since the mathematics
behind the engines are almost identical.
Photon mappers follows individual photons (roughly
speaking) around in the scene, bouncing of
mirrors and other reflective surfaces,
bending through refractive surfaces such as
glass, and finally hitting a single
spot in 3D space, much like a ray tracer
follows the rays projected by the "camera".
When one of these "virtual photons" hits an
absorbing surface, it needs to colorize
or light it.
To store this information,
the majority of the photon tracer
implementations directly modify
the texture associated with the hit surface,
making it easy to e.g. export the new
texture maps again, and have a "pre-lit"
model of the scene that can be used by
another 3D engine.
The reason photon mapping isn't more commonly
in use is that it is a very CPU intensive task.
Or, more correctly, the more rendering time you
put into it, the better the result. You can
trace 100 photons bouncing around the room in
very little CPU time, but it wouldn't look very
nice - only small points of light where the photons
finally hit something. But if you just
leave it running
for a few hours, the "dots" will eventually even
out, and you will end up with nice, smoothly
lit surfaces.
Some tricks and effects that photon mapping is good for:
- Lighting can be influenced by bump maps, such as
the dance of light on the bottom of a pool.
- Diffraction:
Every time a photon hits a refracting surface,
split it in three (or more) photons of different
color and use a slightly different index of
refraction for each of them. This will give
a very realistic diffraction
effect, similar to what you see when white light
hits a prism; rainbows.
See also: POV-Ray, Monte Carlo Simulation