π± π, πβ² = π(π, πβ²) π π, πβ² + ΰΆ±
π»
π π, πβ², πβ²β² π± πβ², πβ²β² ππβ²β²
INFOMAGR β Advanced Graphics
Jacco Bikker - November 2018 - February 2019
Lecture 14 - Bidirectional Welcome! , = (, ) , - - PowerPoint PPT Presentation
INFOMAGR Advanced Graphics Jacco Bikker - November 2018 - February 2019 Lecture 14 - Bidirectional Welcome! , = (, ) , + , , ,
π± π, πβ² = π(π, πβ²) π π, πβ² + ΰΆ±
π»
π π, πβ², πβ²β² π± πβ², πβ²β² ππβ²β²
Jacco Bikker - November 2018 - February 2019
βͺ Introduction: Forward Path Tracing βͺ Multiple Importance Sampling βͺ Virtual Point Lights βͺ Photon Mapping βͺ All Together Now βͺ Exam Questions Sampler
Forward Path Tracing
Advanced Graphics β Bidirectional 3
Images: Simon Brown, sjbrown.co.uk/2011/01/03/two-way-path-tracing
Forward Path Tracing
Tracing paths from the light helps when: βͺ the light is hard to reach βͺ the light cannot be importance sampled. Tracing paths from the eye is better when: βͺ the camera is hard to reach. Many scenes would benefit from both approaches. Now what? βͺ decide on a per-pixel basis? βͺ do both and average? (would that even work?) βͺ something smarter?
Advanced Graphics β Bidirectional 4
Advanced Graphics β Variance Reduction 5
Next Event Estimation: βͺ A ray that is aimed at a light, but hits a diffuse surface is discarded. βͺ A ray that is supposed to sample indirect illumination, but hits a light, is discarded.
When Next Event Estimation Fails
Light sampling: paths to random points on the light yield high variance. Hemisphere sampling (with importance): random rays yield low variance.
Advanced Graphics β Bidirectional 6
When Next Event Estimation Fails
Light sampling: paths to random points on the light yield low variance. Hemisphere sampling (with importance): random rays yield very high variance.
Advanced Graphics β Bidirectional 7
The Cause of Variance
Sampling the function with a constant pdf: correct result, but potentially a lot of variance.
Advanced Graphics β Bidirectional 8
The Cause of Variance
Sampling the function with a pdf proportional to the function itself: correct result, minimal variance (but: this pdf is generally impossible to obtain).
Advanced Graphics β Bidirectional 9
The Cause of Variance
We can also use two pdfs, by taking two samples: βͺ if we keep both samples, we should average them; βͺ otherwise, we need to reject one of the samples.
Advanced Graphics β Bidirectional 10
The Cause of Variance
We can also use two pdfs, by taking two samples: βͺ if we keep both samples, we should average them: π₯1 = 0.5, π₯2 = 0.5 βͺ otherwise, we need to reject one of the samples: π₯1 = 0, π₯2 = 1 (or vice versa). Other blends are also possible. The ideal blend takes the pdfs themselves into account.
Advanced Graphics β Bidirectional 11
βͺ Introduction: Forward Path Tracing βͺ Multiple Importance Sampling βͺ Virtual Point Lights βͺ Photon Mapping βͺ All Together Now βͺ Exam Questions Sampler
Advanced Graphics β Bidirectional 13 βΒ½Ο +Β½Ο π¦ A B C D
Ray one (red), samples the hemisphere, pdf is cos π
π .
Ray two (green-ish), samples the lights, pdf is constant (1/SA).
Advanced Graphics β Bidirectional 14 π¦
Ray one (red), samples the hemisphere, pdf is cos π
π .
Ray two (green-ish), samples the lights, pdf is constant (1/SA).
Multiple Importance Sampling
We now have two samples that may return direct light: βͺ the red ray, which is supposed to sample the hemisphere, so we set its weight to 0; βͺ the green ray, which has a weight of 1. A better blend considers both pdfs.
Advanced Graphics β Bidirectional 15
Multiple Importance Sampling
We now have two samples that may return direct light: βͺ the red ray, which is supposed to sample the hemisphere, so we set its weight to 0; βͺ the green ray, which has a weight of 1. A better blend considers both pdfs.
πππ‘π π
(where π depends on the generated random bounce);
ππ΅.
We can simply average these pdfs: πππ
ππ€ππ ππππ = π₯1 πππ 1 + π₯2 πππ 2
(which is valid if π₯1 + π₯2 = 1). Or, we can use the balance heuristic* to calculate the weights: π₯π =
ππ(π¦) π1 π¦ +π2(π¦) .
*: E. Veach, Robust Monte-Carlo Methods for Light Transport. Ph.D. thesis, 1997.
Advanced Graphics β Bidirectional 16
Multiple Importance Sampling
Practical MIS: We sample irradiance using two samples, each chosen according to its own pdf. πππ
ππ ππ ππ,ππ ππ = πππ‘ππ,ππ ππ π
, πππ
πππ ππ,πππ = 1 ππ΅
If the first sample (i.e., ππ,ππ ππ ) hits a light, we calculate its MIS pdf using the two MIS weights: π₯1 =
πππππ ππ ππ,ππ ππ πππππ ππ ππ,ππ ππ +πππ
πππ ππ,ππ ππ
, π₯2 =
πππ
πππ ππ,ππ ππ
πππππ ππ ππ,πππ +πππ
πππ ππ,ππ ππ
πππ
ππ½π ππ,ππ ππ = π₯1 πππ ππ ππ ππ,ππ ππ + π₯2 πππ πππ(ππ,ππ ππ)
The first sample is now scaled by
1 πππππ½π ππ,ππ ππ instead of 0.
π¦
Advanced Graphics β Bidirectional 17
Multiple Importance Sampling
Practical MIS: We sample irradiance using two samples, each chosen according to its own pdf. πππ
ππ ππ ππ,ππ ππ = πππ‘ππ,ππ ππ π
, πππ
πππ ππ,πππ = 1 ππ΅
If the second sample (i.e. ππ,πππ) hits a light, we calculate its MIS pdf using the two MIS weights: π₯1 =
πππππ ππ ππ,πππ πππππ ππ ππ,πππ +πππ
πππ ππ,πππ
, π₯2 =
πππ
πππ ππ,πππ
πππππ ππ ππ,πππ +πππ
πππ ππ,πππ
πππ
ππ½π ππ,πππ = π₯1 πππ ππ ππ ππ,πππ + π₯2 πππ πππ(ππ,πππ)
Note: we use ππ,πππ now; on the previous slide we evaluated the pdfs for ππ,ππ ππ. π¦
Advanced Graphics β Bidirectional 18
Advanced Graphics β Bidirectional 19
Advanced Graphics β Bidirectional 20
Multiple Importance Sampling
Advanced Graphics β Bidirectional 21
energy returned by k=1 paths EL - LE energy returned by k=2 paths EDL - LDE energy returned by k=3 paths E(D|S)DL L(D|S)DE energy returned by k=4 paths energy returned by k=5 paths
βͺ Introduction: Forward Path Tracing βͺ Multiple Importance Sampling βͺ Virtual Point Lights βͺ Photon Mapping βͺ All Together Now βͺ Exam Questions Sampler
Instant Radiosity*
Idea: Trace from the light sources, record the first hit. Do this for π particles (where π is ~103..105). Each particle becomes a virtual point light. Now, render the scene as usual (rasterization, or Whitted-style ray tracing). At the first diffuse surface, use the VPLs to estimate indirect light, and the lights themselves for direct illumination.
*: A. Keller, Instant Radiosity. SIGGRAPH β97.
Advanced Graphics β Bidirectional 23
Instant Radiosity
Advanced Graphics β Bidirectional 24
Images: M. Hasan, SIGGRAPH Asia β09.
Instant Radiosity
Illumination from π point lights: π π‘ β π¦ = ππ π¦ π ΰ·
π§βππππ‘
π π¦ β π§ cos ππ cos ππ π¦ β π§ 2 π π§ β Where π(π§ β) is the radiance arriving at the diffuse surface from light π¨: π π§ β π¨ = ππ π§ π ππ π¨ cos ππ,π§ Or, after π bounces: π π§ β = ππ(π¨) ΰ·
π=0 π ππ ππ
π cos ππ,ππ
Advanced Graphics β Bidirectional 25 Calculating ππ π¨ : π¦, πππ π¦ = RandomPointOnLight() rad = L(x)/pdf(x)
Instant Radiosity
Using VPLs has some interesting characteristics: βͺ No noise! Those splotches thoughβ¦ βͺ VPLs can bounce: they can represent all indirect light βͺ VPLs cannot represent direct light βͺ #VPLs < #pixels βͺ Evaluating VPLs can be done with or without occlusion βͺ VPL visibility can also be evaluated using shadow maps βͺ Instant Radiosity is a bidirectional technique: we propagate flux when placing the VPLs, and we propagate im importance when connecting to them.
Advanced Graphics β Bidirectional 26
βͺ Introduction: Forward Path Tracing βͺ Multiple Importance Sampling βͺ Virtual Point Lights βͺ Photon Mapping βͺ All Together Now βͺ Exam Questions Sampler
Photon Mapping*
Idea: what if we got rid of visibility queries altogether? With the photon mapping algorithm, we split rendering in two phases: βͺ In phase 1 we deposit flux (Ξ¦) in the scene by tracing a large number of photons; βͺ In phase 2, we estimate illumination using the photon map.
*: Henrik Wann Jensen, The photon map in global illumination. Ph.D. dissertation, 1996.
Advanced Graphics β Bidirectional 28
Photon Mapping
Phase 1: propagating flux. Photon emission: βͺ Point light: emitted in uniformly distributed random directions from the point. βͺ Area light: emitted from random positions on the square, with directions limited to a hemisphere. The emission directions are chosen from a cosine distribution. All photons thus have the same power: their density is the only way to express varying brightness.
Advanced Graphics β Bidirectional 29
Photon Mapping
Phase 1: propagating flux. Surface interaction: A photon that hits a surface may get absorbed or reflected. We chose using random numbers / Russian roulette. Note: In a monochromatic simulation, this maintains the direct relation between photon density and local brightness. With RGB color this relation is lost.
Advanced Graphics β Bidirectional 30
Photon Mapping
Phase 1: propagating flux. Photon storage: At each non-specular path vertex we store the photon:
struct photon { float3 position; // world space position of the photon hit float3 power; // current power level for the photon float3 L; // incident direction };
A photon may be stored multiple times along its path before it gets absorbed. Since the total set of photons represents the illumination, we divide photon power by the total number of stored photons.
Advanced Graphics β Bidirectional 31
Photon Mapping
Phase 2: radiance estimation. In the second pass, we render the scene using rasterization or Whitted-style ray tracing; the photon map is used to estimate illumination. At each non-specular path vertex we estimate the reflected radiance: π π¦, ππ = ΰΆ±
Ξ©π¦
π
π π¦, ππ, ππ ππ π¦, ππ cos ππ πππ
This requires information about the radiance ππ π¦, β¦ arriving over the hemisphere Ξ©π¦. We estimate this radiance by looking at the photons that arrived near π¦: π π¦, ππ β 1 ππ 2 ΰ·
π=1 π
π
π π¦, ππ, ππ βΞ¦ π¦, ππ
Advanced Graphics β Bidirectional 32
Photon Mapping
Phase 2: radiance estimation. We estimate this radiance by looking at the photons that arrived near π¦: π π¦, ππ β 1 ππ 2 ΰ·
π=1 π
π
π π¦, ππ, ππ βΞ¦ π¦, ππ
Note: βͺ We assume that we gathered photons on a disc of radius π . βͺ We assume that the gathered photons belong to the same surface. βͺ Each photon within radius π has the same influence on the estimate.
Advanced Graphics β Bidirectional 33
Photon Mapping
Phase 2: radiance estimation. Instead of using the same weight for each photon we can use a filter: π₯ππ = π½ 1 β 1 β πβπΎ ππ
2
2π 2
1 β πβπΎ , where π½ = 0.918, πΎ = 1.953*. Value ππ
2 is the squared distance between photon π and π¦.
Now: π π¦, ππ β ΰ·
π=1 π
π
π π¦, ππ, ππ βΞ¦ π¦, ππ π₯ππ .
*: Mark J. Pavicic, Convenient Anti-Aliasing Filters that Minimize Bumpy Sampling. In Graphics Gems I.
Advanced Graphics β Bidirectional 34
Photon Mapping
Algorithm characteristics: βͺ Low-frequent noise βͺ Can be used in a rasterizer βͺ Can be used for direct + indirect βͺ Still a bidirectional technique
Advanced Graphics β Bidirectional 35
Advanced Graphics β Bidirectional 36
Advanced Graphics β Bidirectional 37
Photon Mapping
Reducing low-frequency noise: Final gather. Consequence: we cannot sample EDL paths.
Advanced Graphics β Bidirectional 38
βͺ Introduction: Forward Path Tracing βͺ Multiple Importance Sampling βͺ Virtual Point Lights βͺ Photon Mapping βͺ All Together Now (TODO) βͺ Exam Questions Sampler
Advanced Graphics β Bidirectional 48
An exam can be seen as a Monte-Carlo process. Explain why.
Advanced Graphics β Bidirectional 49
After reading the probability tutorial, answer these: a) What is a definite integral? b) What do we mean by an analytical solution? c) How is the Riemann sum defined (mathematically)? d) What is βunivariateβ? e) What is βaliasingβ? f) Define, in your own words, βexpected valueβ. g) What is βdeviationβ in the context of probability theory? And, finally: When using importance sampling, we assume that for π = β,
πβπ π Οπ=1 π π(π) π(π) = πβπ π Οπ=1 π
π(π), if Χ¬
π π π π¦ ππ¦ = 1. Provide one
example for which this is not true.
Advanced Graphics β Bidirectional 50
A scene is illuminated by a single double-sided square light souce. Two algorithms are used to sample the light source: the first picks a random point on a random side of the light source, while the second algorithm only picks random points on the side of the light source facing point π. a) Write down the Monte-Carlo integrator that estimates the illumination on point π using the first algorithm. b) Write down the Monte-Carlo integrator that estimates the illumination on point π using the second algorithm. Note: both methods should obviously produce the same answer,
βͺ Introduction: Forward Path Tracing βͺ Multiple Importance Sampling βͺ Virtual Point Lights βͺ Photon Mapping βͺ All Together Now βͺ Exam Questions Sampler
Jacco Bikker - November 2018 β February 2019
next lecture: βFilteringβ