Ray Tracing - Princeton University Computer Science · Ray Tracing? Paul Debevec Ray Tracing?...
Transcript of Ray Tracing - Princeton University Computer Science · Ray Tracing? Paul Debevec Ray Tracing?...
1
Ray Tracing
Tom Funkhouser
Princeton University
COS 526, Fall 2010
Overview
• Rendering equationo Rendering is integration
• Solution methodso Direct illuminationo Radiosityo Ray tracingo Path tracing
Overview
Ø Rendering equationo Rendering = integration
• Solution methodso Direct illuminationo Radiosityo Ray tracingo Path tracing
Rendering Equation
nv
'x
ωv 'ωv
ωvd
Ω
∫Ω
•+= ωωωωωωω vvvvvvvvdnxLxfxLxL ireo ))(,'()',,'()','()','(
SurfaceSurface
Kajiya 1986
Rendering Equation (2)
nv
'x
x "x
iΘ′
ωv 'ωv
dA
'dA
oΘ
∫ →→→+→=→S
re dAxxGxxVxxLxxxfxxLxxL )',()',()'()"'()"'()"'(
2'
coscos)',(
xxxxG oi
−ΘΘ′
=
Kajiya 1986
Rendering Equation
• Rendering = integrationo Antialiasingo Soft shadowso Indirect illuminationo Caustics
2
Rendering Equation
• Rendering = integrationo Antialiasingo Soft shadowso Indirect illuminationo Caustics
Surface
Eye
Pixel
xx
dAe)L(xLS
P ∫ →=
Rendering Equation
• Rendering = integrationo Antialiasingo Soft shadowso Indirect illuminationo Caustics
Surface
Eye
Light
x
x’
dAxxGxxx)VxL(exxxxfe)(x,xL)wL(x,S
re ),(),(),,( ′′→′→→′+→= ∫r
Rendering Equation
• Rendering = integrationo Antialiasingo Soft shadowso Indirect illuminationo Caustics
Herf
dAxxGxxx)VxL(exxxxfe)(x,xL)wL(x,S
re ),(),(),,( ′′→′→→′+→= ∫r
Rendering Equation
• Rendering = integrationo Antialiasingo Soft shadowso Indirect illuminationo Caustics
wdnw)w(x,Lwwxf)w(x,L)w(x,L ireo
rrrrrrrr)(),,( •′′′+= ∫
Ω
Surface
Eye
Light
x
ω
Surface
ω’
Rendering Equation
• Rendering = integrationo Antialiasingo Soft shadowso Indirect illuminationo Caustics
Debevec
wdnw)w(x,Lwwxf)w(x,L)w(x,L ireo
rrrrrrrr)(),,( •′′′+= ∫
Ω
Rendering Equation
• Rendering = integrationo Antialiasingo Soft shadowso Indirect illuminationo Caustics
Diffuse Surface
Eye
Light
x
ω
SpecularSurface
ω’
wdnw)w(x,Lwwxf)w(x,L)w(x,L ireo
rrrrrrrr)(),,( •′′′+= ∫
Ω
3
Rendering Equation
• Rendering = integrationo Antialiasingo Soft shadowso Indirect illuminationo Caustics
Jensen
wdnw)w(x,Lwwxf)w(x,L)w(x,L ireo
rrrrrrrr)(),,( •′′′+= ∫
Ω
• Rendering integrals are difficult to evaluateo Multiple dimensionso Discontinuities
» Partial occluders» Highlights» Caustics
Drettakis
dAxxGxxx)VxL(exxxxfe)(x,xL)wL(x,S
re ),(),(),,( ′′→′→→′+→= ∫r
Challenge
• Rendering integrals are difficult to evaluateo Multiple dimensionso Discontinuities
» Partial occluders» Highlights» Caustics
Jensen
dAxxGxxx)VxL(exxxxfe)(x,xL)wL(x,S
re ),(),(),,( ′′→′→→′+→= ∫r
Challenge Overview
• Rendering equationo Rendering = integration
Ø Solution methodso Direct illuminationo Radiosityo Ray tracingo Path tracing
Overview
• Rendering equationo Rendering is integration
• Solution methodsØ Direct illuminationo Radiosityo Ray tracingo Path tracing
Direct Illumination
nv
'x
ωv 'ωv
ωvd
Light Camera
Ω
∫Ω
•+=L
dnxLxfxLxL ireo ωωωωωωω vvvvvvvv))(,'()',,'()','()','(
4
OpenGL
Assumedirect illuminationfrom point lights
and ignore visibility
∫Ω
•+= ωωωωωωω vvvvvvvvdnxLxfxLxL ireo ))(,'()',,'()','()','(
nv
'x
ωv 'ωv
Light Camera
Ω
∑=
•+=nlights
iireo nxLxfxLxL
1
))(,'()',,'()','()','(vvvvvvv ωωωωωω
Overview
• Rendering equationo Rendering is integration
• Solution methodso Direct illuminationØ Radiosityo Ray tracingo Path tracing
Radiosity Radiosity
∫ →→→+→=→S
re dAxxGxxVxxLxxxfxxLxxL )',()',()'()"'()"'()"'(
Assume everything is Lambertian
πρ )"'()'( xxxfx r →→=
∫+=S
e dAxxGxxVxLx
xLxL )',()',()()'(
)'()'(π
ρ
∫Ω
= ωθdLB o cosπB
L =
∫+=S
e dAxxGxxVxBx
xBxB )',()',()()'(
)'()'(π
ρ
Convert toRadiosities
Radiosity
∫+=S
e dAxxGxxVxBx
xBxB )',()',()()'(
)'()'(π
ρ
∑=
+=N
jijjiii FBEB
1
ρ
Discretize the surfacesinto “elements”
Rearrange termsand write as matrix
=
−−−−
−−−−−
−−−−
nnnnnnn
nnnnn
n
n
E
E
E
B
B
B
FF
FF
FFF
FF
.
.
.
.
.
.
1...
...
.....
.....
..1
...1
2
1
2
1
,1,
,111,11
,222,221,22
,111,11
ρρρρ
ρρρρρ
Radiosity
5
Radiosity?
Paul Debevec
Radiosity?
Herf
Radiosity?
Jensen
Radiosity?
Henrik Wann Jensen
Path Types Rendering Methods – Path Types
• Radiosityo LD*E
• Ray tracingo LDS*E
• Path tracingo L(D|S)*E
• OpenGLo LDE
John Hart
6
Overview
• Rendering equationo Rendering is integration
• Solution methodso Direct illuminationo Radiosityo Ray tracingo Path tracing
Ray Tracing
Assume only significantindirect illumination due
to perfect specular reflection and refraction
nv
'x
ωv 'ωv
Camera
Ω
Surface Light
specularnxLxfxLxLnlights
iireo +•+= ∑
=1
))(,'()',,'()','()','(vvvvvvv ωωωωωω
∫Ω
•+= ωωωωωωω vvvvvvvvdnxLxfxLxL ireo ))(,'()',,'()','()','(
Ray Tracing?
Paul Debevec
Ray Tracing?
Jensen
Distribution Ray Tracing
∫Ω
•+= ωωωωωωω vvvvvvvvdnxLxfxLxL ireo ))(,'()',,'()','()','(
nv
'x1ωv
'ωv
Ω
Estimate integral Estimate integral for each reflection for each reflection
by random samplingby random sampling 2ωv 3ωv 4ωv
5ωv
6ωv
Also:Also:•• Depth of fieldDepth of field•• Motion blurMotion blur•• etc.etc.
Distribution Ray Tracing?
Henrik Wann Jensen
7
Overview
• Rendering equationo Rendering is integration
• Solution methodso Direct illuminationo Radiosityo Ray tracingo Path tracing
Path Tracing
∫Ω
•+= ωωωωωωω vvvvvvvvdnxLxfxLxL ireo ))(,'()',,'()','()','(
nv
'x
ωv 'ωv
ωvd
Ω
Surface
SurfaceLight
Estimate integral for each pixel
by random sampling
Path Tracing
∫Ω
•+= ωωωωωωω vvvvvvvvdnxLxfxLxL ireo ))(,'()',,'()','()','(
Perform Neumann series expansionPerform Neumann series expansionPerform Neumann series expansionPerform Neumann series expansion
TLLL e += ∫Ω
•= ωωωωωω vvvvvvvdnxgxfxT r ))(,()',,'()',(wherewhere
...32 ++++= eeee LTLTTLLL
Path Tracing
LLee TLTLee TT22LLee TT33LLee
LLee +TL+TLee LLee +TL+TLee+T+T22LLee LLee+…+T+…+T33LLeeLLee
DutréDutré
Ray Tracing vs. Path Tracing
Ray tracingRay tracing Path tracingPath tracingKajiyaKajiya
Bidirectional Path Tracing
• Role of source and receiver can be switched, flux does not change
DutréDutré
8
Bidirectional Path Tracing
DutréDutré
Tracing From Eye
DutréDutré
Tracing from Lights
DutréDutré
Bidirectional Path Tracing
DutréDutré
Bidirectional Path Tracing
(RenderPark 98)(RenderPark 98)
DutréDutré
Bidirectional Ray Tracing?
Henrik Wann Jensen
9
Summary
• Rendering is integrationo Rendering equation
• Different solution methods for different path typeso OpenGL - LDEo Radiosity - LD*Eo Ray tracing – LDS*Eo Path tracing – L(SD)*E