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

Post on 29-Mar-2021

4 views 0 download

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

CS 636 Advanced Rendering Techniques"

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

Photon Mapping" 4/29/20"

Slide Credits Henrik Wann Jensen - UC San Diego

Goal Efficiently create global illumination

images with caustics and complexsurface properties (BRDFs)

Box: Direct Illlumination

CSE168: Rendering Algorithms Henrik Wann Jensen

Box: Global Illlumination

CSE168: Rendering Algorithms Henrik Wann Jensen

Approach Two pass process

Distribute light info into scene(photons)

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

when rendering

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

Two Photon Maps Global

Low resolution photons in all directions Classify

• Direct, Shadow and Indirect

Caustic High resolution at refracting/reflecting

objects

Global Illumination

global photon map caustics photon map

CSE168: Rendering Algorithms Henrik Wann Jensen

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

Photon tracing

• Photon emission

• Photon scattering

• Photon storing

CSE168: Rendering Algorithms Henrik Wann Jensen

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

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

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

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

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

Photon scatteringThe simple way:

Given incoming photon with power Φp

Reflect photon with the power R ∗ Φp

Transmit photon with the power T ∗ Φp

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

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

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

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

Russian Roulette

• Very important!

• Use to eliminate un-important photons

• Gives photons with similar power :)

CSE168: Rendering Algorithms Henrik Wann Jensen

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

and spatial reflection characteristic ofa surface

f(Θi, Θr, λ)

Sampling a BRDF

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

CSE168: Rendering Algorithms Henrik Wann Jensen

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

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

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

A simple test scene

CSE168: Rendering Algorithms Henrik Wann Jensen

Rendering

CSE168: Rendering Algorithms Henrik Wann Jensen

Direct Illumination

CSE168: Rendering Algorithms Henrik Wann Jensen

Specular Reflection

CSE168: Rendering Algorithms Henrik Wann Jensen

Caustics

CSE168: Rendering Algorithms Henrik Wann Jensen

Indirect Illumination

CSE168: Rendering Algorithms Henrik Wann Jensen

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

Radiance Estimate

L

CSE168: Rendering Algorithms Henrik Wann Jensen

Fast estimate

200 photons / 50 photons in radiance estimate

CSE168: Rendering Algorithms Henrik Wann Jensen

Indirect illumination

10000 photons / 500 photons in radiance estimate

CSE168: Rendering Algorithms Henrik Wann Jensen

Global Illumination

100000 photons / 50 photons in radiance estimate

CSE168: Rendering Algorithms Henrik Wann Jensen

Global Illumination

500000 photons / 500 photons in radiance estimate

CSE168: Rendering Algorithms Henrik Wann Jensen

Box

200000 global photons, 50000 caustic photons

CSE168: Rendering Algorithms Henrik Wann Jensen

Box: Global Photons

200000 global photons

CSE168: Rendering Algorithms Henrik Wann Jensen

Fractal Box

200000 global photons, 50000 caustic photons

CSE168: Rendering Algorithms Henrik Wann Jensen

Cornell Box

CSE168: Rendering Algorithms Henrik Wann Jensen

Caustic from a Glass Sphere

Photon Mapping: 10000 photons / 50 photons in radiance estimate

CSE168: Rendering Algorithms Henrik Wann Jensen

Sphereflake Caustic

CSE168: Rendering Algorithms Henrik Wann Jensen

Reflection Inside A Metal Ring

50000 photons / 50 photons in radiance estimate

CSE168: Rendering Algorithms Henrik Wann Jensen

Caustics On Glossy Surfaces

340000 photons / ≈ 100 photons in radiance estimate

CSE168: Rendering Algorithms Henrik Wann Jensen

HDR environment illumination

Using lightprobe from www.debevec.org

CSE168: Rendering Algorithms Henrik Wann Jensen

Cognac Glass

CSE168: Rendering Algorithms Henrik Wann Jensen

Indirect Illumination

CSE168: Rendering Algorithms Henrik Wann Jensen

Little Matterhorn

CSE168: Rendering Algorithms Henrik Wann Jensen

Mies house (3pm)

CSE168: Rendering Algorithms Henrik Wann Jensen

Mies house (6pm)

CSE168: Rendering Algorithms Henrik Wann Jensen

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