Lecture 14 - Bidirectional Welcome! , = (, ) , - - PowerPoint PPT Presentation

β–Ά
lecture 14 bidirectional
SMART_READER_LITE
LIVE PREVIEW

Lecture 14 - Bidirectional Welcome! , = (, ) , - - PowerPoint PPT Presentation

INFOMAGR Advanced Graphics Jacco Bikker - November 2018 - February 2019 Lecture 14 - Bidirectional Welcome! , = (, ) , + , , ,


slide-1
SLIDE 1

𝑱 π’š, π’šβ€² = 𝒉(π’š, π’šβ€²) 𝝑 π’š, π’šβ€² + ΰΆ±

𝑻

𝝇 π’š, π’šβ€², π’šβ€²β€² 𝑱 π’šβ€², π’šβ€²β€² π’†π’šβ€²β€²

INFOMAGR – Advanced Graphics

Jacco Bikker - November 2018 - February 2019

Lecture 14 - β€œBidirectional”

Welcome!

slide-2
SLIDE 2

Today’s Agenda:

β–ͺ Introduction: Forward Path Tracing β–ͺ Multiple Importance Sampling β–ͺ Virtual Point Lights β–ͺ Photon Mapping β–ͺ All Together Now β–ͺ Exam Questions Sampler

slide-3
SLIDE 3

Forward Path Tracing

Forward

Advanced Graphics – Bidirectional 3

= + + + + = + + + +

Images: Simon Brown, sjbrown.co.uk/2011/01/03/two-way-path-tracing

slide-4
SLIDE 4

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?

Forward

Advanced Graphics – Bidirectional 4

slide-5
SLIDE 5

Advanced Graphics – Variance Reduction 5

NEE

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.

slide-6
SLIDE 6

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.

Forward

Advanced Graphics – Bidirectional 6

slide-7
SLIDE 7

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.

Forward

Advanced Graphics – Bidirectional 7

slide-8
SLIDE 8

The Cause of Variance

Sampling the function with a constant pdf: correct result, but potentially a lot of variance.

Forward

Advanced Graphics – Bidirectional 8

slide-9
SLIDE 9

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).

Forward

Advanced Graphics – Bidirectional 9

slide-10
SLIDE 10

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.

Forward

Advanced Graphics – Bidirectional 10

slide-11
SLIDE 11

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.

Forward

Advanced Graphics – Bidirectional 11

slide-12
SLIDE 12

Today’s Agenda:

β–ͺ Introduction: Forward Path Tracing β–ͺ Multiple Importance Sampling β–ͺ Virtual Point Lights β–ͺ Photon Mapping β–ͺ All Together Now β–ͺ Exam Questions Sampler

slide-13
SLIDE 13

Advanced Graphics – Bidirectional 13 βˆ’Β½Ο€ +Β½Ο€ 𝑦 A B C D

MIS

Ray one (red), samples the hemisphere, pdf is cos πœ„

𝜌 .

Ray two (green-ish), samples the lights, pdf is constant (1/SA).

slide-14
SLIDE 14

Advanced Graphics – Bidirectional 14 𝑦

MIS

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.

slide-15
SLIDE 15

Advanced Graphics – Bidirectional 15

MIS

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.

  • 1. Pdf for hemisphere sampling:

π‘‘π‘π‘‘πœ„ 𝜌

(where πœ„ depends on the generated random bounce);

  • 2. Pdf for next event estimation: 1

𝑇𝐡.

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.

slide-16
SLIDE 16

Advanced Graphics – Bidirectional 16

MIS

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.

𝑦

slide-17
SLIDE 17

Advanced Graphics – Bidirectional 17

MIS

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 πœ•π‘—,𝑐𝑠𝑒𝑔. 𝑦

slide-18
SLIDE 18

Advanced Graphics – Bidirectional 18

MIS

slide-19
SLIDE 19

Advanced Graphics – Bidirectional 19

MIS

slide-20
SLIDE 20

Advanced Graphics – Bidirectional 20

MIS

slide-21
SLIDE 21

Multiple Importance Sampling

MIS

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

slide-22
SLIDE 22

Today’s Agenda:

β–ͺ Introduction: Forward Path Tracing β–ͺ Multiple Importance Sampling β–ͺ Virtual Point Lights β–ͺ Photon Mapping β–ͺ All Together Now β–ͺ Exam Questions Sampler

slide-23
SLIDE 23

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.

VPLs

Advanced Graphics – Bidirectional 23

slide-24
SLIDE 24

Instant Radiosity

VPLs

Advanced Graphics – Bidirectional 24

Images: M. Hasan, SIGGRAPH Asia β€˜09.

slide-25
SLIDE 25

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 πœ„π‘—,π‘žπ‘˜

VPLs

Advanced Graphics – Bidirectional 25 Calculating 𝑀𝑓 𝑨 : 𝑦, π‘žπ‘’π‘” 𝑦 = RandomPointOnLight() rad = L(x)/pdf(x)

slide-26
SLIDE 26

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.

VPLs

Advanced Graphics – Bidirectional 26

slide-27
SLIDE 27

Today’s Agenda:

β–ͺ Introduction: Forward Path Tracing β–ͺ Multiple Importance Sampling β–ͺ Virtual Point Lights β–ͺ Photon Mapping β–ͺ All Together Now β–ͺ Exam Questions Sampler

slide-28
SLIDE 28

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.

Photons

Advanced Graphics – Bidirectional 28

slide-29
SLIDE 29

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.

Photons

Advanced Graphics – Bidirectional 29

slide-30
SLIDE 30

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.

Photons

Advanced Graphics – Bidirectional 30

slide-31
SLIDE 31

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.

Photons

Advanced Graphics – Bidirectional 31

slide-32
SLIDE 32

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 𝑂

𝑔

𝑠 𝑦, πœ•π‘ž, πœ•π‘ βˆ†Ξ¦ 𝑦, πœ•π‘ž

Photons

Advanced Graphics – Bidirectional 32

slide-33
SLIDE 33

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.

Photons

Advanced Graphics – Bidirectional 33

slide-34
SLIDE 34

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.

Photons

Advanced Graphics – Bidirectional 34

slide-35
SLIDE 35

Photon Mapping

Algorithm characteristics: β–ͺ Low-frequent noise β–ͺ Can be used in a rasterizer β–ͺ Can be used for direct + indirect β–ͺ Still a bidirectional technique

Photons

Advanced Graphics – Bidirectional 35

slide-36
SLIDE 36

Photons

Advanced Graphics – Bidirectional 36

slide-37
SLIDE 37

Photons

Advanced Graphics – Bidirectional 37

slide-38
SLIDE 38

Photon Mapping

Reducing low-frequency noise: Final gather. Consequence: we cannot sample EDL paths.

Photons

Advanced Graphics – Bidirectional 38

slide-39
SLIDE 39

Today’s Agenda:

β–ͺ Introduction: Forward Path Tracing β–ͺ Multiple Importance Sampling β–ͺ Virtual Point Lights β–ͺ Photon Mapping β–ͺ All Together Now (TODO) β–ͺ Exam Questions Sampler

slide-40
SLIDE 40

Advanced Graphics – Bidirectional 48

Exam

An exam can be seen as a Monte-Carlo process. Explain why.

slide-41
SLIDE 41

Advanced Graphics – Bidirectional 49

Exam

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.

slide-42
SLIDE 42

Advanced Graphics – Bidirectional 50

Exam

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,

  • n average.
slide-43
SLIDE 43

Today’s Agenda:

β–ͺ Introduction: Forward Path Tracing β–ͺ Multiple Importance Sampling β–ͺ Virtual Point Lights β–ͺ Photon Mapping β–ͺ All Together Now β–ͺ Exam Questions Sampler

slide-44
SLIDE 44

INFOMAGR – Advanced Graphics

Jacco Bikker - November 2018 – February 2019

END of β€œBidirectional”

next lecture: β€œFiltering”