<s>
In	O
computer	O
graphics	O
,	O
photon	B-Application
mapping	I-Application
is	O
a	O
two-pass	O
global	B-Algorithm
illumination	I-Algorithm
rendering	O
algorithm	O
developed	O
by	O
Henrik	O
Wann	O
Jensen	O
between	O
1995	O
and	O
2001	O
that	O
approximately	O
solves	O
the	O
rendering	O
equation	O
for	O
integrating	O
light	B-Application
radiance	I-Application
at	O
a	O
given	O
point	O
in	O
space	O
.	O
</s>
<s>
Rays	B-Algorithm
from	O
the	O
light	O
source	O
(	O
like	O
photons	B-Application
)	O
and	O
rays	B-Algorithm
from	O
the	O
camera	O
are	O
traced	O
independently	O
until	O
some	O
termination	O
criterion	O
is	O
met	O
,	O
then	O
they	O
are	O
connected	O
in	O
a	O
second	O
step	O
to	O
produce	O
a	O
radiance	B-Application
value	O
.	O
</s>
<s>
The	O
algorithm	O
is	O
used	O
to	O
realistically	O
simulate	O
the	O
interaction	O
of	O
light	O
with	O
different	O
types	O
of	O
objects	O
(	O
similar	O
to	O
other	O
photorealistic	B-Application
rendering	I-Application
techniques	O
)	O
.	O
</s>
<s>
Specifically	O
,	O
it	O
is	O
capable	O
of	O
simulating	O
the	O
refraction	O
of	O
light	O
through	O
a	O
transparent	O
substance	O
such	O
as	O
glass	O
or	O
water	O
(	O
including	O
caustics	O
)	O
,	O
diffuse	O
interreflection	O
between	O
illuminated	O
objects	O
,	O
the	O
subsurface	B-Algorithm
scattering	I-Algorithm
of	O
light	O
in	O
translucent	O
materials	O
,	O
and	O
some	O
of	O
the	O
effects	O
caused	O
by	O
particulate	O
matter	O
such	O
as	O
smoke	O
or	O
water	O
vapor	O
.	O
</s>
<s>
Photon	B-Application
mapping	I-Application
can	O
also	O
be	O
extended	O
to	O
more	O
accurate	O
simulations	O
of	O
light	O
,	O
such	O
as	O
spectral	O
rendering	O
.	O
</s>
<s>
Progressive	O
photon	B-Application
mapping	I-Application
(	O
PPM	O
)	O
starts	O
with	O
ray	B-Algorithm
tracing	I-Algorithm
and	O
then	O
adds	O
more	O
and	O
more	O
photon	B-Application
mapping	I-Application
passes	O
to	O
provide	O
a	O
progressively	O
more	O
accurate	O
render	O
.	O
</s>
<s>
Unlike	O
path	B-Algorithm
tracing	I-Algorithm
,	O
bidirectional	B-Algorithm
path	I-Algorithm
tracing	I-Algorithm
,	O
volumetric	B-Algorithm
path	I-Algorithm
tracing	I-Algorithm
,	O
and	O
Metropolis	B-Algorithm
light	I-Algorithm
transport	I-Algorithm
,	O
photon	B-Application
mapping	I-Application
is	O
a	O
"	B-Application
biased	I-Application
"	I-Application
rendering	I-Application
algorithm	I-Application
,	O
which	O
means	O
that	O
averaging	O
infinitely	O
many	O
renders	O
of	O
the	O
same	O
scene	O
using	O
this	O
method	O
does	O
not	O
converge	O
to	O
a	O
correct	O
solution	O
to	O
the	O
rendering	O
equation	O
.	O
</s>
<s>
However	O
,	O
it	O
is	O
a	O
consistent	O
method	O
,	O
and	O
the	O
accuracy	O
of	O
a	O
render	O
can	O
be	O
increased	O
by	O
increasing	O
the	O
number	O
of	O
photons	B-Application
.	O
</s>
<s>
As	O
the	O
number	O
of	O
photons	B-Application
approaches	O
infinity	O
,	O
a	O
render	O
will	O
get	O
closer	O
and	O
closer	O
to	O
the	O
solution	O
of	O
the	O
rendering	O
equation	O
.	O
</s>
<s>
For	O
example	O
,	O
as	O
light	O
rays	B-Algorithm
pass	O
through	O
a	O
wine	O
glass	O
sitting	O
on	O
a	O
table	O
,	O
they	O
are	O
refracted	O
and	O
patterns	O
of	O
light	O
are	O
visible	O
on	O
the	O
table	O
.	O
</s>
<s>
Photon	B-Application
mapping	I-Application
can	O
trace	O
the	O
paths	O
of	O
individual	O
photons	B-Application
to	O
model	O
where	O
these	O
concentrated	O
patches	O
of	O
light	O
will	O
appear	O
.	O
</s>
<s>
Photon	B-Application
mapping	I-Application
is	O
particularly	O
adept	O
at	O
handling	O
this	O
effect	O
because	O
the	O
algorithm	O
reflects	O
photons	B-Application
from	O
one	O
surface	O
to	O
another	O
based	O
on	O
that	O
surface	O
's	O
bidirectional	O
reflectance	O
distribution	O
function	O
(	O
BRDF	O
)	O
,	O
and	O
thus	O
light	O
from	O
one	O
object	O
striking	O
another	O
is	O
a	O
natural	O
result	O
of	O
the	O
method	O
.	O
</s>
<s>
Photon	B-Application
mapping	I-Application
differs	O
though	O
in	O
that	O
it	O
separates	O
the	O
light	O
transport	O
from	O
the	O
nature	O
of	O
the	O
geometry	O
in	O
the	O
scene	O
.	O
</s>
<s>
Color	B-General_Concept
bleed	I-General_Concept
is	O
an	O
example	O
of	O
diffuse	O
interreflection	O
.	O
</s>
<s>
Subsurface	B-Algorithm
scattering	I-Algorithm
is	O
the	O
effect	O
evident	O
when	O
light	O
enters	O
a	O
material	O
and	O
is	O
scattered	O
before	O
being	O
absorbed	O
or	O
reflected	O
in	O
a	O
different	O
direction	O
.	O
</s>
<s>
Subsurface	B-Algorithm
scattering	I-Algorithm
can	O
accurately	O
be	O
modeled	O
using	O
photon	B-Application
mapping	I-Application
.	O
</s>
<s>
With	O
photon	B-Application
mapping	I-Application
,	O
light	O
packets	O
called	O
photons	B-Application
are	O
sent	O
out	O
into	O
the	O
scene	O
from	O
the	O
light	O
sources	O
.	O
</s>
<s>
Whenever	O
a	O
photon	B-Application
intersects	O
with	O
a	O
surface	O
,	O
the	O
intersection	O
point	O
and	O
incoming	O
direction	O
are	O
stored	O
in	O
a	O
cache	O
called	O
the	O
photon	B-Application
map	O
.	O
</s>
<s>
Typically	O
,	O
two	O
photon	B-Application
maps	O
are	O
created	O
for	O
a	O
scene	O
:	O
one	O
especially	O
for	O
caustics	O
and	O
a	O
global	O
one	O
for	O
other	O
light	O
.	O
</s>
<s>
A	O
Monte	B-Algorithm
Carlo	I-Algorithm
method	I-Algorithm
called	O
Russian	O
roulette	O
is	O
used	O
to	O
choose	O
one	O
of	O
these	O
actions	O
.	O
</s>
<s>
If	O
the	O
photon	B-Application
is	O
absorbed	O
,	O
no	O
new	O
direction	O
is	O
given	O
,	O
and	O
tracing	O
for	O
that	O
photon	B-Application
ends	O
.	O
</s>
<s>
If	O
the	O
photon	B-Application
reflects	O
,	O
the	O
surface	O
's	O
bidirectional	O
reflectance	O
distribution	O
function	O
is	O
used	O
to	O
determine	O
the	O
ratio	O
of	O
reflected	O
radiance	B-Application
.	O
</s>
<s>
Finally	O
,	O
if	O
the	O
photon	B-Application
is	O
transmitting	O
,	O
a	O
function	O
for	O
its	O
direction	O
is	O
given	O
depending	O
upon	O
the	O
nature	O
of	O
the	O
transmission	O
.	O
</s>
<s>
Once	O
the	O
photon	B-Application
map	O
is	O
constructed	O
(	O
or	O
during	O
construction	O
)	O
,	O
it	O
is	O
typically	O
arranged	O
in	O
a	O
manner	O
that	O
is	O
optimal	O
for	O
the	O
k-nearest	B-General_Concept
neighbor	I-General_Concept
algorithm	I-General_Concept
,	O
as	O
photon	B-Application
look-up	O
time	O
depends	O
on	O
the	O
spatial	O
distribution	O
of	O
the	O
photons	B-Application
.	O
</s>
<s>
Jensen	O
advocates	O
the	O
usage	O
of	O
kd-trees	B-Data_Structure
.	O
</s>
<s>
The	O
photon	B-Application
map	O
is	O
then	O
stored	O
on	O
disk	O
or	O
in	O
memory	O
for	O
later	O
usage	O
.	O
</s>
<s>
In	O
this	O
step	O
of	O
the	O
algorithm	O
,	O
the	O
photon	B-Application
map	O
created	O
in	O
the	O
first	O
pass	O
is	O
used	O
to	O
estimate	O
the	O
radiance	B-Application
of	O
every	O
pixel	O
of	O
the	O
output	O
image	O
.	O
</s>
<s>
At	O
this	O
point	O
,	O
the	O
rendering	O
equation	O
is	O
used	O
to	O
calculate	O
the	O
surface	O
radiance	B-Application
leaving	O
the	O
point	O
of	O
intersection	O
in	O
the	O
direction	O
of	O
the	O
ray	O
that	O
struck	O
it	O
.	O
</s>
<s>
To	O
facilitate	O
efficiency	O
,	O
the	O
equation	O
is	O
decomposed	O
into	O
four	O
separate	O
factors	O
:	O
direct	O
illumination	O
,	O
specular	O
reflection	O
,	O
caustics	O
,	O
and	O
soft	O
indirect	B-Algorithm
illumination	I-Algorithm
.	O
</s>
<s>
For	O
an	O
approximate	O
estimate	O
of	O
indirect	B-Algorithm
illumination	I-Algorithm
,	O
the	O
photon	B-Application
map	O
is	O
used	O
to	O
calculate	O
the	O
radiance	B-Application
contribution	O
.	O
</s>
<s>
Specular	O
reflection	O
can	O
be	O
,	O
in	O
most	O
cases	O
,	O
calculated	O
using	O
ray	B-Algorithm
tracing	I-Algorithm
procedures	O
(	O
as	O
it	O
handles	O
reflections	O
well	O
)	O
.	O
</s>
<s>
The	O
contribution	O
to	O
the	O
surface	O
radiance	B-Application
from	O
caustics	O
is	O
calculated	O
using	O
the	O
caustics	O
photon	B-Application
map	O
directly	O
.	O
</s>
<s>
The	O
number	O
of	O
photons	B-Application
in	O
this	O
map	O
must	O
be	O
sufficiently	O
large	O
,	O
as	O
the	O
map	O
is	O
the	O
only	O
source	O
for	O
caustics	O
information	O
in	O
the	O
scene	O
.	O
</s>
<s>
For	O
soft	O
indirect	B-Algorithm
illumination	I-Algorithm
,	O
radiance	B-Application
is	O
calculated	O
using	O
the	O
photon	B-Application
map	O
directly	O
.	O
</s>
<s>
This	O
contribution	O
,	O
however	O
,	O
does	O
not	O
need	O
to	O
be	O
as	O
accurate	O
as	O
the	O
caustics	O
contribution	O
and	O
thus	O
uses	O
the	O
global	O
photon	B-Application
map	O
.	O
</s>
<s>
In	O
order	O
to	O
calculate	O
surface	O
radiance	B-Application
at	O
an	O
intersection	O
point	O
,	O
one	O
of	O
the	O
cached	O
photon	B-Application
maps	O
is	O
used	O
.	O
</s>
<s>
Gather	O
the	O
N	O
nearest	O
photons	B-Application
using	O
the	O
nearest	B-General_Concept
neighbor	I-General_Concept
search	O
function	O
on	O
the	O
photon	B-Application
map	O
.	O
</s>
<s>
Let	O
S	O
be	O
the	O
sphere	O
that	O
contains	O
these	O
N	O
photons	B-Application
.	O
</s>
<s>
For	O
each	O
photon	B-Application
,	O
divide	O
the	O
amount	O
of	O
flux	O
(	O
real	O
photons	B-Application
)	O
that	O
the	O
photon	B-Application
represents	O
by	O
the	O
area	O
of	O
S	O
and	O
multiply	O
by	O
the	O
BRDF	O
applied	O
to	O
that	O
photon	B-Application
.	O
</s>
<s>
The	O
sum	O
of	O
those	O
results	O
for	O
each	O
photon	B-Application
represents	O
total	O
surface	O
radiance	B-Application
returned	O
by	O
the	O
surface	O
intersection	O
in	O
the	O
direction	O
of	O
the	O
ray	O
that	O
struck	O
it	O
.	O
</s>
<s>
To	O
avoid	O
emitting	O
unneeded	O
photons	B-Application
,	O
the	O
initial	O
direction	O
of	O
the	O
outgoing	O
photons	B-Application
is	O
often	O
constrained	O
.	O
</s>
<s>
Instead	O
of	O
simply	O
sending	O
out	O
photons	B-Application
in	O
random	O
directions	O
,	O
they	O
are	O
sent	O
in	O
the	O
direction	O
of	O
a	O
known	O
object	O
that	O
is	O
a	O
desired	O
photon	B-Application
manipulator	O
to	O
either	O
focus	O
or	O
diffuse	O
the	O
light	O
.	O
</s>
<s>
There	O
are	O
many	O
other	O
refinements	O
that	O
can	O
be	O
made	O
to	O
the	O
algorithm	O
:	O
for	O
example	O
,	O
choosing	O
the	O
number	O
of	O
photons	B-Application
to	O
send	O
,	O
and	O
where	O
and	O
in	O
what	O
pattern	O
to	O
send	O
them	O
.	O
</s>
<s>
It	O
would	O
seem	O
that	O
emitting	O
more	O
photons	B-Application
in	O
a	O
specific	O
direction	O
would	O
cause	O
a	O
higher	O
density	O
of	O
photons	B-Application
to	O
be	O
stored	O
in	O
the	O
photon	B-Application
map	O
around	O
the	O
position	O
where	O
the	O
photons	B-Application
hit	O
,	O
and	O
thus	O
measuring	O
this	O
density	O
would	O
give	O
an	O
inaccurate	O
value	O
for	O
irradiance	O
.	O
</s>
<s>
This	O
is	O
true	O
;	O
however	O
,	O
the	O
algorithm	O
used	O
to	O
compute	O
radiance	B-Application
does	O
not	O
depend	O
on	O
irradiance	O
estimates	O
.	O
</s>
<s>
For	O
soft	O
indirect	B-Algorithm
illumination	I-Algorithm
,	O
if	O
the	O
surface	O
is	O
Lambertian	O
,	O
then	O
a	O
technique	O
known	O
as	O
irradiance	O
caching	O
may	O
be	O
used	O
to	O
interpolate	O
values	O
from	O
previous	O
calculations	O
.	O
</s>
<s>
To	O
avoid	O
unnecessary	O
collision	O
testing	O
in	O
direct	O
illumination	O
,	O
shadow	O
photons	B-Application
can	O
be	O
used	O
.	O
</s>
<s>
During	O
the	O
photon	B-Application
mapping	I-Application
process	O
,	O
when	O
a	O
photon	B-Application
strikes	O
a	O
surface	O
,	O
in	O
addition	O
to	O
the	O
usual	O
operations	O
performed	O
,	O
a	O
shadow	O
photon	B-Application
is	O
emitted	O
in	O
the	O
same	O
direction	O
the	O
original	O
photon	B-Application
came	O
from	O
that	O
goes	O
all	O
the	O
way	O
through	O
the	O
object	O
.	O
</s>
<s>
The	O
next	O
object	O
it	O
collides	O
with	O
causes	O
a	O
shadow	O
photon	B-Application
to	O
be	O
stored	O
in	O
the	O
photon	B-Application
map	O
.	O
</s>
<s>
Then	O
during	O
the	O
direct	O
illumination	O
calculation	O
,	O
instead	O
of	O
sending	O
out	O
a	O
ray	O
from	O
the	O
surface	O
to	O
the	O
light	O
that	O
tests	O
collisions	O
with	O
objects	O
,	O
the	O
photon	B-Application
map	O
is	O
queried	O
for	O
shadow	O
photons	B-Application
.	O
</s>
<s>
Essentially	O
,	O
the	O
filter	O
gives	O
weight	O
to	O
photons	B-Application
 '	O
contributions	O
to	O
radiance	B-Application
depending	O
on	O
how	O
far	O
they	O
are	O
from	O
ray-surface	O
intersections	O
.	O
</s>
<s>
Although	O
photon	B-Application
mapping	I-Application
was	O
designed	O
to	O
work	O
primarily	O
with	O
ray	B-Algorithm
tracers	I-Algorithm
,	O
it	O
can	O
also	O
be	O
extended	O
for	O
use	O
with	O
scanline	B-Algorithm
renderers	I-Algorithm
.	O
</s>
