0% found this document useful (0 votes)
24 views32 pages

Class 09 Global Illumination

Uploaded by

920672
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views32 pages

Class 09 Global Illumination

Uploaded by

920672
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

Global Illumination

Following Photons
• For each light, choose a number of outgoing directions (on the hemisphere or
sphere):
• Emit a photon in each direction

• Each photon travels in a straight line, until it intersects an object


• If Absorbed: Terminate the photon
• If Reflected/Transmitted/Scattered: Photon goes off in a new direction, until it
intersects an object

• When a photon goes through the camera aperture and hits a pixel (on the film), it
contributes to the color of that pixel
Following Photons
• Most of the photons never hit the film (far too inefficient, impractical)
Backward Tracing Photons
• For each pixel, send a ray through the aperture to backward trace a photon that
would have hit the pixel (as in ray tracing)
• If the ray hits an object, cast rays in all directions of the hemisphere in order to
backwards trace incoming photons
• Every new ray that hits another surface spawns an entire hemisphere of rays of its own
(exponential growth makes this impractical)
• Follow all rays until they hit a light source

• Once a ray hits a source, a path for photons (from the light to the pixel) has been
created
• Emit photons along this path, bounce them off all the objects along the path, check to see
if absorbed (if not absorbed, the photon continues on towards the pixel)
• The absorption of photons results in a specific color/brightness of light hitting the pixel
Backward Tracing Photons
• Most paths take too long to find their way back to the light source (inefficient)
Ray Tracing (efficient Backward Tracing)
• Ignore most incoming directions on the hemisphere, only keeping the most
important ones:

• Rays incoming directly from the light source have a lot of photons
• A Shadow Ray is used to account for this incoming light
• This is called direct illumination, since the light is coming directly from a light source
• Reflective objects bounce a lot of photons in the mirror reflection direction
• This incoming light is accounted for with a Reflected Ray
• Transparent objects transmit a lot of photons along the transmitted ray direction
• This incoming light is accounted for with a Transmitted Ray

• Downside: ray tracing ignores a lot of the incoming light, and thus cannot
reproduce many visual effects
Bidirectional Ray Tracing
• Combine forward and backward tracing:
• Step 1: Emit photons from the light, bathe objects in those photons, and record
the result in a light map
• Photons bounce around illuminating shadowed regions, bleeding color, etc.
• Note: light maps don’t change when the camera moves (so they can be precomputed)
• Step 2: Ray trace the scene, using the light map to estimate indirect light (from
the ignored directions of the hemisphere)

• IMPORTANT: Still treat the most important directions on the hemisphere with ray
tracing, for increased accuracy
• Shadow Rays for direct illumination
• Reflected Rays
• Transmitted Rays
Light Maps
• Light maps work great for soft shadows, color bleeding, etc.
• They can also generate many other interesting effects:
Recall: Lighting Equation
• Multiplying the BRDF by an incoming irradiance gives the outgoing radiance
𝑑𝐿𝑜 𝑑𝑢𝑒 𝑡𝑜 𝑖 (𝜔𝑖 , 𝜔𝑜 ) = 𝐵𝑅𝐷𝐹 𝜔𝑖 , 𝜔𝑜 𝑑𝐸𝑖 (𝜔𝑖 )

• For even more realistic lighting, we’ll bounce light all around the scene
𝑑𝐸
• It’s tedious to convert between 𝐸 and 𝐿, so use 𝐿 = to obtain:
𝑑𝜔 cos 𝜃𝑙𝑖𝑔ℎ𝑡
𝑑𝐿𝑜 𝑑𝑢𝑒 𝑡𝑜 𝑖 (𝜔𝑖 , 𝜔𝑜 ) = 𝐵𝑅𝐷𝐹 𝜔𝑖 , 𝜔𝑜 𝐿𝑖 𝑑𝜔𝑖 cos 𝜃𝑖

• Then,

𝐿𝑜 𝜔𝑜 = න 𝐵𝑅𝐷𝐹 𝜔𝑖 , 𝜔𝑜 𝐿𝑖 cos 𝜃𝑖 𝑑𝜔𝑖


𝑖∈ℎ𝑒𝑚𝑖

Changed 𝑖 ∈ 𝑖𝑛 for “incoming directions” to 𝑖 ∈ ℎ𝑒𝑚𝑖 for


“hemisphere”
Lighting Equation
• Explicitly add the dependencies on surface location 𝑥 and incoming angle 𝜔𝑖
• Add an emission term 𝐿𝑒 , so 𝑥 can be a location on the surface of an actual light too

𝐿𝑜 𝑥, 𝜔𝑜 = 𝐿𝑒 𝑥, 𝜔𝑜 + න 𝐵𝑅𝐷𝐹 𝑥, 𝜔𝑖 , 𝜔𝑜 𝐿𝑖 (𝑥, 𝜔𝑖 ) cos 𝜃𝑖 𝑑𝜔𝑖


𝑖∈ℎ𝑒𝑚𝑖

• Incoming light from direction 𝜔𝑖 left some other surface point 𝑥′ going in direction −𝜔𝑖
• So, replace 𝐿𝑖 𝑥, 𝜔𝑖 with 𝐿𝑜 (𝑥 ′ , −𝜔𝑖 )

𝐿𝑜 𝑥, 𝜔𝑜 = 𝐿𝑒 𝑥, 𝜔𝑜 + න 𝐵𝑅𝐷𝐹 𝑥, 𝜔𝑖 , 𝜔𝑜 𝐿𝑜 (𝑥 ′ , −𝜔𝑖 ) cos 𝜃𝑖 𝑑𝜔𝑖


𝑖∈ℎ𝑒𝑚𝑖
An Implicit Equation
• Computing the outgoing radiance 𝐿𝑜 𝑥, 𝜔𝑜 on a particular surface requires knowing the
outgoing radiance 𝐿𝑜 (𝑥 ′ , −𝜔𝑖 ) from all the other (relevant) surfaces
• But the outgoing radiance from those other surfaces (typically) depends on the outgoing
radiance from the surface under consideration (circular dependencies)

𝐿𝑜 𝑥, 𝜔𝑜 = 𝐿𝑒 𝑥, 𝜔𝑜 + න 𝐿𝑜 (𝑥 ′ , −𝜔𝑖 ) 𝐵𝑅𝐷𝐹 𝑥, 𝜔𝑖 , 𝜔𝑜 cos 𝜃𝑖 𝑑𝜔𝑖


𝑖∈ℎ𝑒𝑚𝑖
Reflected Light Emission Reflected Light BRDF incident angle
UNKNOWN KNOWN UNKNOWN KNOWN KNOWN

• Fredholm Integral Equation of the second kind (extensively studied) given in canonical form
with kernel 𝑘 𝑢, 𝑣 by:
𝑙 𝑢 = 𝑒 𝑢 + ‫𝑢 𝑘 𝑣 𝑙 ׬‬, 𝑣 𝑑𝑣
Aside: Participating Media
• “Air” typically contains participating
media (e.g. dust, droplets, smoke, etc.)
• 𝐿 should actually be defined over all of 3D
space (not just on 2D surfaces)
• The incoming light should be considered
in a sphere centered around each point in
3D space

• Neglecting this assumes that “air” is a


vacuum
• That restricts 𝐿 to surfaces
Discretization of the Lighting Equation
• Choose 𝑝 points, each representing a chunk of surface area, which is a 2D
discretization (for participating media, volume chunks are 3D)
• For each of the 𝑝 points: Choose 𝑞 outgoing directions, each representing a
chunk of solid angles of the hemisphere (or sphere), which is a 2D discretization

• 𝐿𝑜 and 𝐿𝑒 then each have 𝑝 ∗ 𝑞 unknowns, a 4D (or 5D) discretization


• Represent them by vectors: 𝐿 and 𝐸, each with length 𝑝 ∗ 𝑞
• The light transport “kernel” matrix 𝐾 has size 𝑝 ∗ 𝑞 by 𝑝 ∗ 𝑞

• The linear system of equations is: 𝐿 = 𝐸 + 𝐾𝐿 or 𝐼 − 𝐾 𝐿 = 𝐸


• Solution: 𝐿 = 𝐼 − 𝐾 −1 𝐸 = 𝐼 + 𝐾 + 𝐾 2 + ⋯ 𝐸
• Since 𝐾 bounces only a fraction of the light (the rest is absorbed), higher powers are smaller
(and the infinite series can be truncated)
Power Series
𝐿 = 𝐸 + 𝐾𝐸 + 2
𝐾 𝐸 + 3
𝐾 𝐸 +⋯

Emission directly
from Light Sources

Direct Illumination
(light bounces
only once) Global Illumination
(indirect lighting,
two bounces) Global
Illumination Etc.
(indirect lighting,
three bounces)
Power Series
Tractability
• A typical scene might warrant thousands or tens of thousands of area chunks
• So, 𝑝 could be 1e3, 1e4, 1e5, 1e6, etc.
• Incoming light could vary significantly across the hemisphere
• So, 𝑞 might need to be 1e2, 1e3, 1e4, etc.
• 𝐿 and 𝐸 would then range in length from 1e5 to 1e10
• The matrix 𝐾 would then range in size from 1e5 by 1e5 up to 1e10 by 1e10

• 𝐾 would have between 1e10 and 1e20 entries!

• This tractability analysis is for the 4D problem (5D is even worse)


• The curse of dimensionality makes problems in 4D and 5D (and higher) hard to
discretize (with numerical quadrature)
Addressing Tractability
• Separate the diffuse and specular contributions (to be treated separately)

Diffuse:
• Assume all materials are purely diffuse (i.e. no specular contributions)
• Compute the view-independent global illumination for the entire scene
• This can be done in a pre-processing step

Specular:
• Compute (view-dependent) specular illumination on-the-fly as the camera moves
• Use the Phong Shading model (or any other model)
Radiosity & Albedo
• Radiosity: power per unit surface area leaving a surface (similar to irradiance, but outgoing
instead of incoming):
𝑑Φ
𝐵 𝑥 = = න 𝐿𝑜 (𝑥, 𝜔𝑜 ) cos 𝜃𝑜 𝑑𝜔𝑜
𝑑𝐴 ℎ𝑒𝑚𝑖
• When 𝐿𝑜 is independent of 𝜔𝑜 (i.e. for a purely diffuse surface):
𝑑Φ
𝐵 𝑥 = = 𝐿(𝑥) න cos 𝜃𝑜 𝑑𝜔𝑜 = 𝜋𝐿 𝑥
𝑑𝐴 ℎ𝑒𝑚𝑖
• Albedo: a “reflection coefficient” relating incoming light hitting a surface patch (irradiance 𝐸𝑖 )
to outgoing light emitted in all possible directions

𝜌 𝑥 =න 𝐵𝑅𝐷𝐹(𝑥, 𝜔𝑜 , 𝜔𝑖 ) cos 𝜃𝑜 𝑑𝜔𝑜


ℎ𝑒𝑚𝑖
• When the BRDF is independent of 𝜔𝑜 and 𝜔𝑖 (i.e. for a purely diffuse surface):

𝜌 𝑥 = 𝐵𝑅𝐷𝐹(𝑥) න cos 𝜃𝑜 𝑑𝜔𝑜 = 𝜋 𝐵𝑅𝐷𝐹(𝑥)


ℎ𝑒𝑚𝑖
Purely Diffuse Surface Lighting Equation
• Recall: 𝐿𝑜 𝑥, 𝜔𝑜 = 𝐿𝑒 𝑥, 𝜔𝑜 + ‫∈𝑖׬‬ℎ𝑒𝑚𝑖 𝐿𝑜 (𝑥 ′ , −𝜔𝑖 )𝐵𝑅𝐷𝐹 𝑥, 𝜔𝑖 , 𝜔𝑜 cos 𝜃𝑖 𝑑𝜔𝑖
• Multiply through by cos𝜃𝑜 𝑑𝜔𝑜 and integrate over the hemisphere (i.e. over 𝑑𝜔𝑜 ) to obtain:

𝐵 𝑥 =𝐸 𝑥 +න 𝐵(𝑥′)𝐵𝑅𝐷𝐹 𝑥, 𝜔𝑖 , 𝜔𝑜 cos 𝜃𝑖 𝑑𝜔𝑖


𝑖∈ℎ𝑒𝑚𝑖

• 𝐵 is a 2D function (of 𝑥), whereas 𝐿 was a 4D function (of 𝑥 and 𝜔𝑜 )

• Assume that all surfaces have a diffuse BRDF independent of angle:


𝜌(𝑥)
𝐵 𝑥 =𝐸 𝑥 + න 𝐵 𝑥 ′ cos 𝜃𝑖 𝑑𝜔𝑖
𝜋 𝑖∈ℎ𝑒𝑚𝑖
Recall: Solid Angle vs. Cross-Sectional Area
• The (orthogonal) cross-sectional area is 𝑑𝐴 𝑐𝑜𝑠𝜃
𝑑𝐴𝑠𝑝ℎ𝑒𝑟𝑒 𝑑𝐴 𝑐𝑜𝑠𝜃
• So, 𝑑𝜔 = = (so, the solid angle varies with the tilt 𝜃 and the distance 𝑟)
𝑟2 𝑟2

S0
unit
sphere
d

r N̂


surface
patch
dA
Replace Solid Angle with Surface Area
𝑑𝐴 𝑐𝑜𝑠𝜃 𝑑𝐴′ 𝑐𝑜𝑠𝜃𝑜
• Note: 𝑑𝜔 = means that 𝑑𝜔𝑖 =
𝑟2 𝑥−𝑥 ′ 22

𝜌(𝑥) ′ x'
• So, 𝐵 𝑥 = 𝐸 𝑥 + ‫∈𝑖׬‬ℎ𝑒𝑚𝑖 𝐵 𝑥 cos 𝜃𝑖 𝑑𝜔𝑖 is: o
𝜋

𝐵 𝑥 = 𝐸 𝑥 + 𝜌(𝑥) න 𝐵 𝑥
cos 𝜃𝑖 cos 𝜃𝑜 ′
′ − i dA'
′ 2 𝑑𝐴
𝑖∈ℎ𝑒𝑚𝑖 𝜋 𝑥−𝑥 2 i
i
• Let 𝑉 𝑥, 𝑥 ′ = 1 when 𝑥 and 𝑥′ are mutually visible and
x
𝑉 𝑥, 𝑥 ′ = 0 otherwise, then:
′ ′
cos 𝜃𝑖 cos 𝜃𝑜 ′
𝐵 𝑥 = 𝐸 𝑥 + 𝜌(𝑥) න 𝐵 𝑥 𝑉 𝑥, 𝑥 ′ 2 𝑑𝐴
𝑎𝑙𝑙 𝑥 ′ 𝜋 𝑥−𝑥 2
A Tractable Discretization
• Choose 𝑝 points, each representing a chunk of surface area (a 2D discretization)
cos 𝜃𝑖 cos 𝜃𝑗
• Then 𝐵𝑖 = 𝐸𝑖 + 𝜌𝑖 σ𝑗≠𝑖 𝐵𝑗 𝐹𝑖𝑗 with a purely geometric 𝐹𝑖𝑗 = 𝑉 𝑥𝑖 , 𝑥𝑗 2 𝐴𝑗
𝜋 𝑥𝑖 −𝑥𝑗
2
• Rearrange to 𝐵𝑖 − 𝜌𝑖 σ𝑗≠𝑖 𝐵𝑗 𝐹𝑖𝑗 = 𝐸𝑖 and put into matrix form:

1 −𝜌1 𝐹12 ⋯ −𝜌1 𝐹1𝑝 𝐵1 𝐸1


−𝜌2 𝐹21 1 ⋯ −𝜌2 𝐹2𝑝 𝐵2 𝐸2
⋮ = ⋮
⋮ ⋮ ⋱ ⋮
−𝜌𝑝 𝐹𝑝1 −𝜌𝑝 𝐹𝑝2 ⋯ 1 𝐵𝑝 𝐸𝑝
• For 𝑝 ranging from 1e3 to 1e6: 𝐵 and 𝐸 have the same size, and the matrix has 1e6 to 1e12
entries (still large, but 1e4 to 1e8 times smaller than previously)
Form Factor
𝐹෠𝑖𝑗 𝐹෠𝑖𝑗
• Write 𝐹𝑖𝑗 = 𝑉 𝑥𝑖 , 𝑥𝑗 and 𝐹𝑗𝑖 = 𝑉 𝑥𝑖 , 𝑥𝑗 with
𝐴𝑖 𝐴𝑗
(symmetric) form factor:
cos 𝜃𝑖 cos 𝜃𝑗

𝐹𝑖𝑗 = 2 𝐴𝑖 𝐴𝑗
𝜋 𝑥𝑖 − 𝑥𝑗
2
• 𝐹෠𝑖𝑗 represents how the light energy leaving one surface
impacts the other surface, and vice versa (and only
depends on the geometry, not on the light)

• The visibility between between 𝑥𝑖 and 𝑥𝑗 , i.e. 𝑉 𝑥𝑖 , 𝑥𝑗 ,


also only depends on the geometry (and can be included
into 𝐹෠𝑖𝑗 if desired)
Understanding the Form Factor
• Place a unit hemisphere at a surface point 𝑥𝑖

• Project a surface onto the unit hemisphere, noting


𝑑𝐴 𝑐𝑜𝑠𝜃 𝐴𝑗 cos𝜃𝑗
that 𝑑𝜔 = gives 2 as the result
𝑟2 𝑥𝑖 −𝑥𝑗
2
• Project the result downwards onto the circular base
of the hemisphere, which multiples by cos 𝜃𝑖
• Recall ‫∈𝑖׬‬ℎ𝑒𝑚𝑖 cos 𝜃𝑖 𝑑𝜔𝑖 = 𝜋, the area of the unit circle
• Finally, divide the result by the total area 𝜋 to get the
fraction of the circle occupied

cos 𝜃𝑖 cos 𝜃𝑗
• Overall, this gives: 𝐹𝑖𝑗 = 2 𝐴𝑗
𝜋 𝑥𝑖 −𝑥𝑗
2
Implementation
Precomputation:
• Create a hemicube, and divide each face into sub-squares
(as small as desired)
• For each sub-square, use hemisphere projection (from
the last slide) to pre-compute its contribution to 𝐹𝑖𝑗

For each surface chunk:


• Place the hemicube at a surface point 𝑥𝑖
• Surface patches (from other objects) are projected onto
the hemicube in order to approximate 𝐹𝑖𝑗 (using the pre-
computed values for the sub-squares)
• The five hemicube faces can each be treated as a film
plane where sub-squares are pixels (standard scanline
rasterization)
• The depth buffer is used for the visibility term
Hemicube Scanline Rasterization
Iterative Solvers
• For large matrices, iterative solvers are typically far more accurate than direct methods (like
Cramer’s rule) for computing inverses
• Iterative methods start with an initial guess, and subsequently iteratively improve it

2 1 𝑥 8 𝑥 2
• Consider = with solution =
1 2 𝑦 10 𝑦 4
𝑥 0
• Start with an initial guess of 𝑦 =
0

• Jacobi iteration (solve both equations, using the old values to get the new values):
𝑛𝑒𝑤 8−𝑦 𝑜𝑙𝑑 𝑛𝑒𝑤 10−𝑥 𝑜𝑙𝑑
•𝑥 = and 𝑦 =
2 2

• Gauss Seidal iteration (always use the most up to date values):


𝑐𝑢𝑟𝑟𝑒𝑛𝑡 8−𝑦 𝑐𝑢𝑟𝑟𝑒𝑛𝑡 𝑐𝑢𝑟𝑟𝑒𝑛𝑡 10−𝑥 𝑐𝑢𝑟𝑟𝑒𝑛𝑡
•𝑥 = and 𝑦 =
2 2
Jacobi vs. Gauss-Seidal
Iteration Jacobi Gauss Seidel
x y x y
1 0 0 0 0
2 4 5 4 3
3 1.5 3 2.5 3.75
4 2.5 4.25 2.125 3.9375
5 1.875 3.75 2.03125 3.984375
6 2.125 4.0625 2.007813 3.996094
7 1.96875 3.9375 2.001953 3.999023
8 2.03125 4.015625 2.000488 3.999756
9 1.9921875 3.984375 2.000122 3.999939
10 2.0078125 4.00390625 2.000031 3.999985
11 1.998046875 3.99609375 2.000008 3.999996
12 2.001953125 4.000976563 2.000002 3.999999
13 1.999511719 3.999023438 2 4
14 2.000488281 4.000244141 2 4
15 1.99987793 3.999755859 2 4
16 2.00012207 4.000061035 2 4
17 1.999969482 3.999938965 2 4
18 2.000030518 4.000015259 2 4
19 1.999992371 3.999984741 2 4
20 2.000007629 4.000003815 2 4
Better Initial Guess
Iteration Jacobi Gauss Seidal
x y x y
1 2 3 2 3
2 2.5 4 2.5 3.75
3 2 3.75 2.125 3.9375
4 2.125 4 2.03125 3.984375
5 2 3.9375 2.007813 3.996094
6 2.03125 4 2.001953 3.999023
7 2 3.984375 2.000488 3.999756
8 2.0078125 4 2.000122 3.999939
9 2 3.99609375 2.000031 3.999985
10 2.001953125 4 2.000008 3.999996
11 2 3.999023438 2.000002 3.999999
12 2.000488281 4 2 4
13 2 3.999755859 2 4
14 2.00012207 4 2 4
15 2 3.999938965 2 4
16 2.000030518 4 2 4
17 2 3.999984741 2 4
18 2.000007629 4 2 4
19 2 3.999996185 2 4
20 2.000001907 4 2 4
Iterative Radiosity
• Gathering - update one surface by collecting light energy from all surfaces
• Shooting - update all surfaces by distributing light energy from one surface
• Sorting and Shooting - choose the surface with the greatest un-shot light energy and use
shooting to distribute it to other surfaces
• start by shooting light energy out of the lights onto objects (the brightest light goes first)
• then the object that would reflect the most light goes next, etc.
• Sorting and Shooting with Ambient - start with an initial guess for ambient lighting and do
sorting and shooting afterwards
Iterative Radiosity

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy