71
CSCE 641: Photon Mapping Jinxiang Chai

CSCE 641: Photon Mapping Jinxiang Chai. Outline Rendering equation Photon mapping

  • View
    220

  • Download
    0

Embed Size (px)

Citation preview

CSCE 641: Photon Mapping

Jinxiang Chai

Outline

• Rendering equation

• Photon mapping

Ray Tracing and Photon Mapping

What are differences between the two rendered pictures?

Ray Tracing and Photon Mapping

causticscolor bleedingWhat are differences between the two rendered pictures?

The Rendering Equation

( , )r rL x

( , )i iL x

idi

r

r i

2

( , ) ( , ) ( , )

( , ) ( , ) ( , )cos

o o e o r o

e o r i o i i i i

H

L x L x L x

L x f x L x d

The Rendering Equation

( , )r rL x

( , )i iL x

idi

r

r i

2

( , ) ( , ) ( , )

( , ) ( , ) ( , )cos

o o e o r o

e o r i o i i i i

H

L x L x L x

L x f x L x d

Outgoing Emitted Reflected

The Rendering Equation

( , )r rL x

( , )i iL x

idi

r

r i

2

( , ) ( , ) ( , )

( , ) ( , ) ( , )cos

o o e o r o

e o r i o i i i i

H

L x L x L x

L x f x L x d

Emitted light [known]

The Rendering Equation

( , )r rL x

( , )i iL x

idi

r

r i

2

( , ) ( , ) ( , )

( , ) ( , ) ( , )cos

o o e o r o

e o r i o i i i i

H

L x L x L x

L x f x L x d

BRDF [known]

BRDF (bi-directional reflectance distribution function)

( , )r rL x

( , )i iL x

idi

r

r i

i

rrri E

xLxf

),(),(

How to model surface reflectance property?

for a given incoming direction, the amount of light that is reflected in a certain outgoing direction

Dimensionality of the BRDF

• This is 6-D function - x: 2D position

- (θi,φi): incoming direction

- (θr,φr): outgoing direction

• Usually represented as 4-D - ignoring x

- homogenous material property

Gonioreflectometer

Scattering Models

The BSSRDF• Bidirectional Surface Scattering Reflectance-

Distribution Function

( , , )( , , ) r i i r ri i r r

i

dL x xS x x

d

( , )r rdL x

( , )i iL x

idi

r

ri

rx ix

Translucency

The Rendering Equation

( , )r rL x

( , )i iL x

idi

r

r i

2

( , ) ( , ) ( , )

( , ) ( , ) ( , )cos

o o e o r o

e o r i o i i i i

H

L x L x L x

L x f x L x d

BRDF [known]

Emitted light [known]

Directional irradiance

[unknown]

[unknown]

Global Illumination

• Various Rendering techniques solve some portion of the rendering equation

• If a technique approximates the integral, it is part of the family of “Global Illumination”

Global Illumination Techniques

• Radiosity

• Ray Tracing

• Photon Mapping

Radiosity

• Solves geometry term in form factor• Approximates integral completely for

diffuse-diffuse– No reflection or transmission

2

( , ) ( , ) ( , )

( , ) ( , ) ( , )cos

o o e o r o

e o r i o i i i i

H

L x L x L x

L x f x L x d

Ray Tracing

• Works well for reflection and refraction• Solves geometry eq. through ray

intersection tests• Solves emission properly• Only solves integral for reflection and

refraction to maxDepth– Diffuse reflectance ignored

2

( , ) ( , ) ( , )

( , ) ( , ) ( , )cos

o o e o r o

e o r i o i i i i

H

L x L x L x

L x f x L x d

Global Illumination Techniques

• Radiosity

• Ray Tracing

• Photon Mapping

Photon Mapping

Photon Mapping

Two challenges:

- Q1: how to compute the incoming radiance Li?

- Q2: how to efficiently evaluate the integral?

Photon Mapping

Two challenges:

- Q1: how to compute the incoming radiance Li?

A1: compute Li based on precomputed photon map

- Q2: how to efficiently evaluate the integral?

A2: compute the integral based on Monte Carlo ray tracing

Photon Mapping

• Is often used to simulate the interaction of light with a variety transparent substances (caustics)

- glass, water

- diffuse inter-reflections between illuminated objects

- effects of particulate matter, e.g. smoke

- etc.

Photon Mapping

Phase I: shoot and store photons - photons are shot from the light into the scene

- photons are allowed to interact with objects in the environment

- where photons fall are stored in special data structure called a “photon map”

- 10000s of photons not billions (Statistical approximation based on density)

Photon Mapping

Phase I: shoot and store photons [Forward] - photons are shot from the light into the scene

- photons are allowed to interact with objects in the environment

- where photons fall are stored in special data structure called a “photon map”

- 10000s of photons not billions (Statistical approximation based on density)

Shooting Photons

Point light source

directional light square light general light

Shooting Photons

Point light source

directional light square light general light

The power of light

The number of photonsThe power of an emitted photon

Pseudocode for Emission of Photons from Point Light Source

Pseudocode for Emission of Photons from Point Light Source

Basic idea:

- Radiant intensity as a probability function.

- Generate photons by sampling the probability function.

Photon Mapping

Phase I: shoot and store photons - photons are shot from the light into the scene

- photons are allowed to interact with objects in the environment

- where photons fall are stored in special data structure called a “photon map”

- 10000s of photons not billions (Statistical approximation based on density)

Photon Tracing

• Photons are only stored when it hits diffuse surface

• Specular surface does not store any photons.

Photon Map

Photon Map

What information does each photon store?

Photon Map

The photon:

Placed in K-D tree for efficient access

Three Photon Maps

Caustic photon map - interact with at least one specular surface

Global photon map - interact with diffuse surfaces only

Volume photon map - indirect illumination of participating medium

Global Photon Map

• Basic idea: - Launch photons from the light sources in all directions

- Store a photon (position, power, and direction) in each intersection of the photon with the scene.

- Compute the kind of interaction with the surface by using the Russian roulette.

Global Photon Map

The types of interactions are:

- Diffusion: the photon is reflected in a random direction (projected hemisphere) or taking into account a BRDF.

- Reflection: Perfect reflection of the photon.

- Refraction: The photon is refracted using Snell's law.

- Absorption: We don't launch that photon again.

The Russian roulette method decides which interaction to consider in function of the material.

Caustics Photon Map

• The global photon map has very weak caustics effects. We need to construct an additional map only for caustics.

- Launch the rays only over the objects that can generate caustics.

- Store the photons when they hit a diffuse surface only if previously it hit a reflective or refractive surface.

Caustics & Global Photon Map

The caustics photon map The global photon map

Photon Mapping

Phase 2: Gather illumination

- use ray tracing

- direct illumination determined by ray tracing

- indirect illumination determined by stochastically sampling photon map (gather photon within volume in the required direction)

Rendering Using Photon Map

Rendering Using Photon Map

Two main issues:

- How to compute incoming radiance Li?

- How to evaluate the integral efficiently?

Basic idea: Radiance Estimate

Basic Idea: Radiance Estimate

How to evaluate reflected radiance based on the photon map?

Basic Idea: Radiance Estimate

Evaluate the radiance based on nearby photons

Basic idea: Radiance Estimate

Evaluate the radiance based on nearby photons:

Find N photons with the shortest distance to the intersection point

Radiance Estimate Using Photon Map

Radiance Estimate Using Photon Map

Radiance Estimate Using Photon Map

Radiance Estimate Using Photon Map

Radiance Estimate Using Photon Map

locally flat surface

Radiance Estimate Using Photon Map

locally flat surface

Radiance Estimated Using Photon Map

200000 photons

500 photons100 photons

Photon Mapping: Rendering

Photon Mapping: Rendering

Photon Mapping: Rendering

Li,l: direct illumination by light from the light sources

Li,c: caustics—indirect illumination from the light sources via specular surface

Li,d: indirect illumination from the light sources (diffuse inter-reflection)

Light Sources

Light Sources

Li,l

Li,d

Li,c

Photon Mapping: Rendering

Photon Mapping: Rendering

Diffuse surfaces Specular surfaces

Photon mapping: the rendering equation

Photon mapping: the rendering equation

Accurate evaluation of the direct illumination

Similar to the evaluation of shadow rays in ray tracing

Photon mapping: the rendering equation

Evaluation of the Specular and Glossy term

Similar to the evaluation of reflection rays in ray tracing

Photon mapping: the rendering equation

Evaluation of the caustics

Evaluate this term using the caustics photon map directly

Photon mapping: the rendering equation

Evaluation of the indirect diffuse illumination

Accurate evaluation of the integral using monte carlo ray tracing method

Results

Ray tracingglobal photon map

- 200000 photons

- 100 photons for estimate

Cornell box with water