Ray Tracing - Princeton University Computer Science · Ray Tracing? Paul Debevec Ray Tracing?...

9
1 Ray Tracing Tom Funkhouser Princeton University COS 526, Fall 2010 Overview Rendering equation o Rendering is integration Solution methods o Direct illumination o Radiosity o Ray tracing o Path tracing Overview Rendering equation o Rendering = integration Solution methods o Direct illumination o Radiosity o Ray tracing o Path tracing Rendering Equation n v ' x ϖ v ' ϖ v ϖ v d + = ϖ ϖ ϖ ϖ ϖ ϖ ϖ v v v v v v v v d n x L x f x L x L i r e o ) )( , ' ( ) ' , , ' ( ) ' , ' ( ) ' , ' ( Surface Surface Kajiya 1986 Rendering Equation (2) n v ' x x " x i Θϖ v ' ϖ v dA ' dA o Θ + = S r e dA x x G x x V x x L x x x f x x L x x L ) ' , ( ) ' , ( ) ' ( ) " ' ( ) " ' ( ) " ' ( 2 ' cos cos ) ' , ( x x x x G o i - Θ Θ= Kajiya 1986 Rendering Equation Rendering = integration o Antialiasing o Soft shadows o Indirect illumination o Caustics

Transcript of Ray Tracing - Princeton University Computer Science · Ray Tracing? Paul Debevec Ray Tracing?...

Page 1: Ray Tracing - Princeton University Computer Science · Ray Tracing? Paul Debevec Ray Tracing? Jensen Distribution Ray Tracing ∫ Ω ω= ω+ ωω ωω• ω v v v v v v v v Lo (x

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

∫ →→→+→=→S

re dAxxGxxVxxLxxxfxxLxxL )',()',()'()"'()"'()"'(

2'

coscos)',(

xxxxG oi

−ΘΘ′

=

Kajiya 1986

Rendering Equation

• Rendering = integrationo Antialiasingo Soft shadowso Indirect illuminationo Caustics

Page 2: Ray Tracing - Princeton University Computer Science · Ray Tracing? Paul Debevec Ray Tracing? Jensen Distribution Ray Tracing ∫ Ω ω= ω+ ωω ωω• ω v v v v v v v v Lo (x

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)(),,( •′′′+= ∫

Ω

Page 3: Ray Tracing - Princeton University Computer Science · Ray Tracing? Paul Debevec Ray Tracing? Jensen Distribution Ray Tracing ∫ Ω ω= ω+ ωω ωω• ω v v v v v v v v Lo (x

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))(,'()',,'()','()','(

Page 4: Ray Tracing - Princeton University Computer Science · Ray Tracing? Paul Debevec Ray Tracing? Jensen Distribution Ray Tracing ∫ Ω ω= ω+ ωω ωω• ω v v v v v v v v Lo (x

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

Page 5: Ray Tracing - Princeton University Computer Science · Ray Tracing? Paul Debevec Ray Tracing? Jensen Distribution Ray Tracing ∫ Ω ω= ω+ ωω ωω• ω v v v v v v v v Lo (x

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

Page 6: Ray Tracing - Princeton University Computer Science · Ray Tracing? Paul Debevec Ray Tracing? Jensen Distribution Ray Tracing ∫ Ω ω= ω+ ωω ωω• ω v v v v v v v v Lo (x

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

Page 7: Ray Tracing - Princeton University Computer Science · Ray Tracing? Paul Debevec Ray Tracing? Jensen Distribution Ray Tracing ∫ Ω ω= ω+ ωω ωω• ω v v v v v v v v Lo (x

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é

Page 8: Ray Tracing - Princeton University Computer Science · Ray Tracing? Paul Debevec Ray Tracing? Jensen Distribution Ray Tracing ∫ Ω ω= ω+ ωω ωω• ω v v v v v v v v Lo (x

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

Page 9: Ray Tracing - Princeton University Computer Science · Ray Tracing? Paul Debevec Ray Tracing? Jensen Distribution Ray Tracing ∫ Ω ω= ω+ ωω ωω• ω v v v v v v v v Lo (x

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