CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon...

54
CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM 8:50PM Photon Mapping 4/29/20

Transcript of CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon...

Page 1: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

CS 636 Advanced Rendering Techniques"

Dr. David Breen"Online Wednesday 6PM → 8:50PM"

Photon Mapping" 4/29/20"

Page 2: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Slide Credits Henrik Wann Jensen - UC San Diego

Page 3: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Goal Efficiently create global illumination

images with caustics and complexsurface properties (BRDFs)

Page 4: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Box: Direct Illlumination

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 5: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Box: Global Illlumination

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 6: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Approach Two pass process

Distribute light info into scene(photons)

Store light flux in photon map Combine photon info with ray tracing

when rendering

Page 7: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Emitting Photons Photons emitted from light sources Traced through scene Stored (energy & direction) at surfaces Russian Roulette determines if photon

is absorbed or reflected BRDF used to determine direction of

reflection

Page 8: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Two Photon Maps Global

Low resolution photons in all directions Classify

• Direct, Shadow and Indirect

Caustic High resolution at refracting/reflecting

objects

Page 9: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Global Illumination

global photon map caustics photon map

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 10: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

The photon map datastructure

The photons are stored in a left balanced kd-tree

struct photon = float position[3];rgbe power; // power packed as 4 byteschar phi, theta; // incoming directionshort flags;

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 11: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Photon tracing

• Photon emission

• Photon scattering

• Photon storing

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 12: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Photon emission

Given Φ Watt lightbulb.Emit N photons.Each photon has the power Φ

N Watt.

• Photon power depends on the number of emittedphotons. Not on the number of photons in thephoton map.

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 13: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

What is a photon?

• Flux (power) - not radiance!

• Collection of physical photons? A fraction of the light source power? Several wavelengths combined into one entity

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 14: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Diffuse point light

Generate random directionEmit photon in that direction

// Find random directiondo x = 2.0*random()-1.0;y = 2.0*random()-1.0;z = 2.0*random()-1.0;

while ( (x*x + y*y + z*z) > 1.0 );

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 15: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Example: Diffuse square light

- Generate random position p on square- Generate diffuse direction d- Emit photon from p in direction d

// Generate diffuse directionu = random();v = 2*π*random();d = vector( cos(v)

√u, sin(v)

√u,

√1− u );

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 16: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Surface interactionsThe photon is

• Stored (at diffuse surfaces) and

• Absorbed (A) or

• Reflected (R) or

• Transmitted (T )

A+R+ T = 1.0

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 17: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Photon scatteringThe simple way:

Given incoming photon with power Φp

Reflect photon with the power R ∗ Φp

Transmit photon with the power T ∗ Φp

Page 18: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Photon scatteringThe simple way:

Given incoming photon with power Φp

Reflect photon with the power R ∗ Φp

Transmit photon with the power T ∗ Φp

• Risk: Too many low-powered photons - wasteful!

• When do we stop (systematic bias)?

• Photons with similar power is a good thing.

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 19: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Russian Roulette

• Statistical technique

• Known from Monte Carlo particle physics

• Introduced to graphics by Arvo and Kirk in 1990

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 20: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Russian Roulette ExampleSurface reflectance: R = 0.5Incoming photon: Φp = 2 W

r = random();if ( r < 0.5 )reflect photon with power 2 W

elsephoton is absorbed

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 21: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Russian Roulette IntuitionSurface reflectance: R = 0.5200 incoming photons with power: Φp = 2 Watt

Reflect 100 photons with power 2 Watt instead of200 photons with power 1 Watt.

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 22: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Russian Roulette

• Very important!

• Use to eliminate un-important photons

• Gives photons with similar power :)

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 23: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Bi-directional ReflectionDistribution Function (BRDF) function which defines the spectral

and spatial reflection characteristic ofa surface

f(Θi, Θr, λ)

Page 24: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Sampling a BRDF

fr(x, ~ωi, ~ωo) = w1fr,1(x, ~ωi, ~ωo) + w2fr,2(x, ~ωi, ~ωo)

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 25: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Sampling a BRDF

fr(x, ~ωi, ~ωo) = w1 · fr,d + w2 · fr,s

r = random()·(w1 + w2);if ( r < w1 )reflect diffuse photon

elsereflect specular

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 26: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Rendering Ray trace scene Use photon maps

to approximate low importance shadingvalues

to evaluate Bi-directional ReflectionDistribution Function (BRDF)

to perform shadow calculation to calculate caustics

Page 27: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Ray Tracing vs.Radiance Approximation Approximation

Diffuse surfaces Deep in ray tree (contribution less

significant) Shadow calculations

Ray Tracing Direct illumination High gloss, specular surfaces

Page 28: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

A simple test scene

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 29: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Rendering

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 30: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Direct Illumination

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 31: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Specular Reflection

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 32: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Caustics

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 33: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Indirect Illumination

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 34: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Radiance Estimate

L(x, ~ω) =∫

Ωfr(x, ~ω′, ~ω)L′(x, ~ω′) cos θ′ dω

=∫

Ωfr(x, ~ω′, ~ω)

dΦ2(x, ~ω′)dω cos θ′dA

cos θ′dω

=∫

Ωfr(x, ~ω′, ~ω)

dΦ2(x, ~ω′)dA

≈n∑p=1

fr(x, ~ω′p, ~ω)∆Φp(x, ~ω′p)

πr2

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 35: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Radiance Estimate

L

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 36: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Fast estimate

200 photons / 50 photons in radiance estimate

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 37: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Indirect illumination

10000 photons / 500 photons in radiance estimate

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 38: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Global Illumination

100000 photons / 50 photons in radiance estimate

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 39: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Global Illumination

500000 photons / 500 photons in radiance estimate

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 40: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Box

200000 global photons, 50000 caustic photons

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 41: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Box: Global Photons

200000 global photons

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 42: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Fractal Box

200000 global photons, 50000 caustic photons

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 43: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Cornell Box

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 44: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Caustic from a Glass Sphere

Photon Mapping: 10000 photons / 50 photons in radiance estimate

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 45: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Sphereflake Caustic

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 46: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Reflection Inside A Metal Ring

50000 photons / 50 photons in radiance estimate

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 47: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Caustics On Glossy Surfaces

340000 photons / ≈ 100 photons in radiance estimate

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 48: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

HDR environment illumination

Using lightprobe from www.debevec.org

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 49: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Cognac Glass

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 50: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Indirect Illumination

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 51: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Little Matterhorn

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 52: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Mies house (3pm)

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 53: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

Mies house (6pm)

CSE168: Rendering Algorithms Henrik Wann Jensen

Page 54: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/... · 2020. 4. 29. · Photon Mapping: 10000 photons / 50 photons in radiance estimate CSE168: Rendering Algorithms

More Information

Realistic Image

Synthesis

Using Photon

Mapping

Realistic Image

Synthesis

Using Photon

Mapping

Realistic Im

age S

ynthesis U

sing P

hoton M

apping

Realistic Image

Synthesis

Using Photon

Mapping

Foreword by Pat Hanrahan

Realistic Image

Synthesis

Using Photon

Mapping

Henrik Wann Jensen

Jensen

Foreword by Pat Hanrahan

The creation of realistic three-dimensional images is central to computer graphics. Photon mapping, an extension of ray tracing, makes it possible to efficiently simulate global illumination in complex scenes. Photo mapping can simulate caustics (focused light, such as shimmering waves at the bottom of a swimming pool), diffuse inter-reflections (e.g., the `bleeding' of colored light from a red wall onto a white floor, giving the floor a reddish tint), and participating media (e.g., clouds or smoke). This book is a practical guide to photon mapping; it provides both the theory and the practical insight necessary to implement photon mapping and simulate all types of direct and indirect illumination efficiently.

A K PETERS LTD.A K

PETERS

Henrik Wann Jensen

http://graphics.ucsd.edu/~henrik/papers/book/

CSE168: Rendering Algorithms Henrik Wann Jensen