INFOMAGR – Advanced Graphics Jacco Bikker - November 2018 - February 2019 Lecture 14 - “ Bidirectional ” Welcome! 𝑱 𝒚, 𝒚 ′ = 𝒉(𝒚, 𝒚 ′ ) 𝝑 𝒚, 𝒚 ′ + න 𝝇 𝒚, 𝒚 ′ , 𝒚 ′′ 𝑱 𝒚 ′ , 𝒚 ′′ 𝒆𝒚′′ 𝑻
Today’s Agenda: ▪ Introduction: Forward Path Tracing ▪ Multiple Importance Sampling ▪ Virtual Point Lights ▪ Photon Mapping ▪ All Together Now ▪ Exam Questions Sampler
Advanced Graphics – Bidirectional 3 Forward Forward Path Tracing = + + + + = + + + + Images: Simon Brown, sjbrown.co.uk/2011/01/03/two-way-path-tracing
Advanced Graphics – Bidirectional 4 Forward 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 – 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.
Advanced Graphics – Bidirectional 6 Forward 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 7 Forward 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 8 Forward The Cause of Variance Sampling the function with a constant pdf: correct result, but potentially a lot of variance.
Advanced Graphics – Bidirectional 9 Forward 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 10 Forward 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 11 Forward 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 .
Today’s Agenda: ▪ Introduction: Forward Path Tracing ▪ Multiple Importance Sampling ▪ Virtual Point Lights ▪ Photon Mapping ▪ All Together Now ▪ Exam Questions Sampler
Advanced Graphics – Bidirectional 13 MIS −½π +½π 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 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. Ray one (red), samples the hemisphere, pdf is cos 𝜄 𝜌 . Ray two (green-ish), samples the lights, pdf is constant (1/SA). 𝑦
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.
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 𝑞𝑒𝑔 𝑜𝑓𝑓 (𝜕 𝑗,𝑐𝑠𝑒𝑔 ) 1 The first sample is now scaled by 𝑞𝑒𝑔 𝑁𝐽𝑇 𝜕 𝑗,𝑐𝑠𝑒𝑔 instead of 0 .
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 𝜕 𝑗,𝑐𝑠𝑒𝑔 .
Advanced Graphics – Bidirectional 18 MIS
Advanced Graphics – Bidirectional 19 MIS
Advanced Graphics – Bidirectional 20 MIS
Advanced Graphics – Bidirectional 21 MIS Multiple Importance Sampling = + + + + = + + + + energy returned energy returned energy returned energy returned energy returned by k=4 paths by k=5 paths by k=1 paths by k=2 paths by k=3 paths EL - LE EDL - LDE E(D|S)DL L(D|S)DE
Today’s Agenda: ▪ Introduction: Forward Path Tracing ▪ Multiple Importance Sampling ▪ Virtual Point Lights ▪ Photon Mapping ▪ All Together Now ▪ Exam Questions Sampler
Advanced Graphics – Bidirectional 23 VPLs Instant Radiosity* Idea: Trace from the light sources, record the first hit. Do this for 𝑂 particles (where 𝑂 is ~ 10 3 .. 10 5 ). 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. S IGGRAPH ‘97.
Advanced Graphics – Bidirectional 24 VPLs Instant Radiosity Images: M. Hasan, SIGGRAPH Asi a ‘09.
Advanced Graphics – Bidirectional 25 VPLs Instant Radiosity Illumination from 𝑂 point lights: 𝑀 𝑡 ← 𝑦 = 𝑙 𝑒 𝑦 𝑊 𝑦 ↔ 𝑧 cos 𝜄 𝑝 cos 𝜄 𝑗 𝑀 𝑧 ← 𝑦 − 𝑧 2 𝜌 𝑧∈𝑊𝑄𝑀𝑡 Where 𝑀(𝑧 ←) is the radiance arriving at the diffuse surface from light 𝑨 : 𝑀 𝑧 ← 𝑨 = 𝑙 𝑒 𝑧 𝑀 𝑓 𝑨 cos 𝜄 𝑗,𝑧 Calculating 𝑀 𝑓 𝑨 : 𝜌 𝑦, 𝑞𝑒𝑔 𝑦 = RandomPointOnLight() Or, after 𝑜 bounces: rad = L(x)/pdf(x) 𝑜 𝑙 𝑒 𝑞 𝑘 𝑀 𝑧 ← = 𝑀 𝑓 (𝑨) ෑ cos 𝜄 𝑗,𝑞 𝑘 𝜌 𝑘=0
Advanced Graphics – Bidirectional 26 VPLs 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.
Today’s Agenda: ▪ Introduction: Forward Path Tracing ▪ Multiple Importance Sampling ▪ Virtual Point Lights ▪ Photon Mapping ▪ All Together Now ▪ Exam Questions Sampler
Recommend
More recommend