Class 09 Global Illumination
Class 09 Global Illumination
Following Photons
• For each light, choose a number of outgoing directions (on the hemisphere or
sphere):
• Emit a photon in each direction
• 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,
• Incoming light from direction 𝜔𝑖 left some other surface point 𝑥′ going in direction −𝜔𝑖
• So, replace 𝐿𝑖 𝑥, 𝜔𝑖 with 𝐿𝑜 (𝑥 ′ , −𝜔𝑖 )
• 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
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
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
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:
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 𝐹𝑖𝑗
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