PhotonMapping e.g.refrac=onofacaus=c - - PDF document

photon mapping
SMART_READER_LITE
LIVE PREVIEW

PhotonMapping e.g.refrac=onofacaus=c - - PDF document

Refrac=onofaCaus=c MonteCarloraytracinghandlesall pathsoflight:L(D|S)*E,butnotequally well HasdifficultysamplingLS*DS*Epaths, PhotonMapping


slide-1
SLIDE 1

1

Photon
Mapping


Jan
Kautz


Featuring
images
swiped
from
 Henrik
Wann
Jensen


Refrac=on
of
a
Caus=c


  • Monte‐Carlo
ray
tracing
handles
all


paths
of
light:
L(D|S)*E,
but
not
equally
 well


  • Has
difficulty
sampling
LS*DS*E
paths,


e.g.
refrac=on
of
a
caus=c


  • Path
tracing
would
need
a
very
lucky


first
hit


  • Bidirec=onal
ray
tracing
can
find


caus=c,
but
reflec=on
of
caus=c
s=ll
 needs
lucky
first
hit
during
path
tracing


Photon
Mapping


  • Jensen
EGRW
95,
96

  • Simulates
the
transport
of
individual


photons


  • Photons
emiXed
from
light
sources

  • Photons
bounce
off
of
specular


surfaces


  • Photons
deposited
on
diffuse
surfaces


– Held
in
a
3‐D
spa=al
data
structure
 – Surfaces
need
not
be
parameterized


  • Photons
collected
by
path
tracing
from


eye


Why
Map
Photons?


  • High
variance
in
Monte‐Carlo


renderings
results
in
noise


  • Collec=on
of
deposited
photons


into
a
“photon
map”
(a
3‐D
 spa=al
data
structure)
provides
a
 flux
density
es=mate


  • Flux
samples
filtered
easier
than


path
samples,
resul=ng
in
error
at
 lower
frequencies


  • Error
is
a
result
of
bias,
which


decreases
as
the
number
of
 samples
increase


  • And,
oh
yeah,
it’s
a
lot
faster


The
scene
above
contains
glossy
 surfaces,
and
was
rendered
in
50
 minutes
using
photon
mapping.
The
 same
scene
took
6
hours
for
render
 with
Radiance,
a
rendering
system
that
 used
radiosity
for
diffuse
reflec=on
and
 path
tracing
for
glossy
reflec=on. 


What
is
a
Photon?


  • A
photon
p
is
a
par=cle
of
light


that
carries
flux
ΔΦp(xp,
ωp)


– Power:
ΔΦp
–
magnitude
(in
 WaXs)
and
color
of
the
flux
it
 carries,
stored
as
an
RGB
triple
 – Posi=on:
xp
–
loca=on
of
the
 photon
 – Direc=on:
ωp
–
the
incident
 direc=on
ωi
used
to
compute
 irradiance


  • Photons
vs.
rays


– Photons
propogate
flux
 – Rays
gather
radiance
 ωp ΔΦp xp

Sources


  • Point
source


– Photons
emiXed
uniformly
in
all
 direc=ons


  • Power
of
source
(W)
distributed


evenly
among
photons


  • Flux
of
each
photon
equal
to
source


power
divided
by
total
#
of
photons


  • For
example,
a
60W
light
bulb
would


send
out
a
total
of
100K
photons,
 each
carrying
a
flux
ΔΦ
of
0.6
mW


  • Photons
sent
out
once
per
simula=on,


not
con=nuously
as
in
radiosity


slide-2
SLIDE 2

2

Mixed
Surfaces


  • Surfaces
have
specular
and


diffuse
components


– 
ρd
–
diffuse
reflectance
 – 
ρs
–
specular
reflectance
 – 
ρd
+
ρs
<
1
(conserva=on
of
 energy)


  • Let
ζ
be
a
uniform
random
value


from
0
to
1


  • If
ζ
<
ρd
then
reflect
diffuse

  • Else
if
ζ
<
ρd
+
ρs
then
reflect


specular


  • Otherwise
absorb


ρd = 50% ρs = 30%

Russian
RouleXe


  • Arvo
&
Kirk,
S90

  • Reflected
flux
only
a
frac=on
of


incident
flux


  • Aker
several
reflec=ons,
spending


a
lot
of
=me
keeping
track
of
very
 liXle
flux


  • Instead,
completely
absorb
some


photons
and
completely
reflect


  • thers

at
full
power

  • Spend
=me
tracing
fewer
full


power
photons


  • Probability
of
reflectance
is
the


reflectance
ρ.


  • Probability
of
absorp=on
is
1
–
ρ.



?

ρ = 60%

Storing
Photons


  • Uses
a
kd‐tree
–
a
sequence
of
axis‐

aligned
par==ons


– 2‐D
par==ons
are
lines
 – 3‐D
par==ons
are
planes


  • Axis
of
par==ons
alternates
wrt


depth
of
the
tree


  • Average
access
=me
is
O(log
n)

  • Worst
case
O(n)
when
tree
is


severely
lopsided


  • Need
to
maintain
a
balanced
tree,


which
can
be
done
in
O(n
log
n)


  • Can
find
k
nearest
neighbors
in


O(k
+
log
n)
=me
using
a
heap


K‐D
Tree


  • Given
a
large
number
of
points
p1,…,pn
in
3D


space
we
want
to
classify
them
and
be
able
to
 make
fast
queries:


– Find
all
the
points
within
a
cuboid
 – Find
all
the
points
within
a
neighbourhood
of
a
 given
point


  • These
points
are
photon
posi=ons
on
surfaces.


K‐D
Tree


  • A
K‐D
tree
is
just
an
axis
aligned
BSP
tree.

  • Each
 node
 of
 the
 tree
 stores
 a
 separa=ng


plane,
defined
by
the
median
value
along
one


  • f
the
coordinates.


  • The
leaves
of
the
tree
contain
the
original
data


points.



K‐D
Tree


  • Write
pi
=
(x1i,
x2i,
x3i)

  • Let
xj*
be
the
median
of
the
values
of
the
jth
coordinate


(j=1,2,3).


  • Start
with
x1*
which
will
par==on
the
original
set
of
points


into
two
sets
(divided
along
the
X
axis).


  • Now
apply
the
same
procedure
to
each
of
the
lek‐
and
right‐

sets,
except
now
subdivide
on
x2*



  • Now
apply
the
same
procedure
recursively
to
each
of
these


subsets
except
now
subdivide
on
x3*



  • Keep
applying
this
recursively
un=l
each
leaf
of
the
tree


contains
a
data
point.



slide-3
SLIDE 3

3

K‐D
Tree
2D
Example
 K‐D
Tree
2D
Example
 K‐D
Tree
2D
Example
 K‐D
Tree
Code


KDTree makeKDTree(int n, point_kd p[], int depth) /*returns a kd-tree for the n 3-dimensional points in p - assume all indices start from 1*/ { if n==1 return a leaf containing p[1]; /*base case*/ x = median of values of (depth mod 3) coordinate in the points; pLeft is the set of points to the left of x and pRight is the set to the right; leftNode = makeKDTree(n/2,pLeft,depth+1); rightNode = makeKDTree(n/2,pRight,depth+1); /*assumes that the median splits the points exactly in two*/ /*compose a new node and return*/ return compose(leftNode,x,rightNode); }

K‐D
Tree
Advantages


  • Using
a
K‐D
tree
solu=on
does
not
depend
on


the
 providing
 a
 mesh
 on
 the
 surfaces
 –
 the
 distribu=on
 of
 the
 photons
 is
 maintained
 independently
 of
 the
 representa=on
 of
 the
 surfaces


  • The
method
does
not
rely
on
‘regular’
surfaces


such
as
polygons,
but
could
equally
well
apply
 to
fractal
type
surfaces.


Reflected
Radiance


  • Recall
the
reflected
radiance
equa=on

  • Convert
incident
radiance
into
incident
flux

  • Reflected
radiance
in
terms
of
incident
flux

  • Numerically


ΔA = πr2

slide-4
SLIDE 4

4

How
Many
Photons?


  • How
big
is
the
disk
radius
r?

  • Large
enough
that
the
disk


surrounds
the
n
nearest
 photons.


  • The
number
of
photons
used
for


a
radiance
es=mate
n
is
usually
 between
50
and
500.


Radiance
es=mate
using
50
photons 
 Radiance
es=mate
using
500
 photons 


ΔA = πr2

Filtering


  • Too
few
photons
cause
blurry


results


  • Simple
averaging
produces
a
box


filtering
of
photons


  • Photons
nearer
to
the
sample


should
be
weighted
more
heavily


  • Results
in
a
cone
filtering
of


photons


Mul=ple
Photon
Maps


  • Global
L(S|D)*D
photon
map


– Photon
s=cks
to
diffuse
surface
 and
bounces
to
next
surface
(if
 it
survives
Russian
rouleXe)
 – Photons
don’t
s=ck
to
specular
 surfaces


  • Caus=c
LSS*D
photon
map


– High
resolu=on
 – Light
source
usually
emits
 photons
only
in
direc=ons
that
 hit
the
thing
crea=ng
the
caus=c


Caustic map photons Global map photons

Rendering


  • Rendered
by
glossy‐surface


distributed
ray
tracing


  • When
ray
hits
first
diffuse


surface…


– Compute
direct
illumina=on
 – Compute
reflected
radiance


  • f
caus=c
map
photons


– Ignore
global
map
photons
 – Importance
sample
BRDF
fr
 as
usual
 – Use
global
photon
map
to
 importance
sample
incident
 radiance
func=on
Li
 – Evaluate
reflectance
integral
 by
cas=ng
rays
and
 accumula=ng
radiances
from
 global
photon
map


First
diffuse
intersec=on.
 Return
radiance
of
caus=c
 map
photons
here,
but
 ignore
global
map
photons 
 Use
global 
 map 
 photons
to 
 return 
 radiance 
 when 
 evalua=ng 
 Li
at
first 
 diffuse 
 intersec=on . 


Examples


Direct
Illumina=on


www.bennolan.com

Examples


Global
Photon
Map


www.bennolan.com

slide-5
SLIDE 5

5

Examples


Indirect
Illumina=on


www.bennolan.com

Examples


Final
Rendering


www.bennolan.com

Photon
Map
Example


http://www.vrayrender.com/stuff/PMapTutorial/

Photon
Map
Example


http://www.vrayrender.com/stuff/PMapTutorial/

Photon
Mapping


  • One
of
the
recent
of
the
established
global
illumina=on


solu=ons


  • Has
a
pre‐rendering
phase
to
es=mate
global
illumina=on

  • A
path
tracing
phase
for
the
final
rendering
(final


gathering)


  • It
is
significantly
faster
than
path
tracing
(minutes


compared
to
hours),
and
the
pre‐rendering
phase
only
has
 to
be
done
once.


  • Most
=me
goes
into
the
final
rendering
phase,
and
in


par=cular
in
es=ma=ng
the
radiance
from
nearby
photons.