lecture 7 path tracing
play

Lecture 7 - Path Tracing Welcome! , = (, ) , - PowerPoint PPT Presentation

INFOMAGR Advanced Graphics Jacco Bikker - November 2016 - February 2017 Lecture 7 - Path Tracing Welcome! , = (, ) , + , , ,


  1. INFOMAGR – Advanced Graphics Jacco Bikker - November 2016 - February 2017 Lecture 7 - “Path Tracing” Welcome! 𝑱 𝒚, 𝒚 ′ = 𝒉(𝒚, 𝒚 ′ ) 𝝑 𝒚, 𝒚 ′ + 𝝇 𝒚, 𝒚 ′ , 𝒚 ′′ 𝑱 𝒚 ′ , 𝒚 ′′ 𝒆𝒚′′ 𝑻

  2. Today’s Agenda:  Introduction  Path Tracing

  3. Advanced Graphics – Path Tracing 3 Introduction Previously in Advanced Graphics The Rendering Equation: 𝑀 𝑝 𝑦, 𝜕 𝑝 = 𝑀 𝐹 𝑦, 𝜕 𝑝 + 𝑔 𝑠 𝑦, 𝜕 𝑝 , 𝜕 𝑗 𝑀 𝑗 𝑦, 𝜕 𝑗 cos 𝜄 𝑗 𝑒𝜕 𝑗 𝛻 …which models light transport as it happens in the real world, by summing:  Direct illumination: 𝑀 𝐹 (𝑦, 𝜕 𝑝 )  Indirect illumination, or reflected light: 𝛻 𝑔 𝑠 𝑦, 𝜕 𝑝 , 𝜕 𝑗 𝑀 𝑗 𝑦, 𝜕 𝑗 cos 𝜄 𝑗 𝑒𝜕 𝑗 We used quantities flux 𝛸 (joules per second), radiance 𝑀 (flux per 𝑛 2 per sr) and irradiance 𝐹 (joules per second per 𝑛 2 ).

  4. Advanced Graphics – Path Tracing 4 Introduction Previously in Advanced Graphics Particle transport: As an alternative to discrete flux / radiance / irradiance, we can reason about light transport in terms of particle transport.  Flux then becomes the number of emitted photons;  Radiance the number of photons travelling through a unit area in a unit direction;  Irradiance the number of photons arriving on a unit area. A BRDF tells us how many particles are absorbed, and how outgoing particles are distributed. The distribution depends on the incident and exitant direction.

  5. Advanced Graphics – Path Tracing 5 Introduction Previously in Advanced Graphics Probabilities: We can also reason about the behavior of a single photon. In that case, the BRDF tells us the probability of a photon being absorbed, or leaving in a certain direction.

  6. Advanced Graphics – Path Tracing 6 Introduction Previously in Advanced Graphics BRDFs: The BRDF describes how incoming light is absorbed or scattered. More accurately: for an incoming direction 𝜕 𝑗 and an outgoing direction 𝜕 𝑝 , it defines the relation between received irradiance and reflected radiance. A physically based BRDF has some important properties: 𝝏 𝒋  𝑔 𝑠 𝜕 𝑝 , 𝜕 𝑗 ≥ 0 𝒐  𝑔 𝑠 𝜕 𝑝 , 𝜕 𝑗 = 𝑔 𝑠 𝜕 𝑗 , 𝜕 𝑝  𝛻 𝑔 𝑠 𝜕 𝑝 , 𝜕 𝑗 cos 𝜄 𝑝 𝑒𝜕 𝑝 ≤ 1 𝑏𝑚𝑐𝑓𝑒𝑝 Example: diffuse BRDF, 𝑔 𝑠 ω 𝑝 , ω 𝑗 = . 𝜌 Note that the diffuse BRDF is view independent; 𝜕 𝑝 is irrelevant. It does however take into account 𝜕 𝑗 : this affects how radiance is converted to irradiance.

  7. Advanced Graphics – Path Tracing 7 Introduction Previously in Advanced Graphics Monte Carlo integration: Complex integrals can be approximated by replacing them by the expected value of a stochastic experiment.  Soft shadows: randomly sample the area of a light source;  Glossy reflections: randomly sample the directions in a cone;  Depth of field: randomly sample the aperture;  Motion blur: randomly sample frame time. In the case of the rendering equation, we are dealing with a recursive integral . Pat ath tracing ng: eval aluat ating this integral usin ing a a rand andom wal alk .

  8. Today’s Agenda:  Introduction  Path Tracing

  9. Advanced Graphics – Path Tracing 9 Path Tracing Solving the Rendering Equation Let’s start with direct illumination: For a screen pixel, diffuse surface point 𝑞 with normal 𝑜 is directly visible. What is the radiance travelling via 𝑞 towards the eye? Answer: 𝑀 𝑝 𝑞, 𝜕 𝑝 = 𝑔 𝑠 𝑞, 𝜕 𝑝 , 𝜕 𝑗 𝑀 𝑒 𝑞, 𝜕 𝑗 cos 𝜄 𝑗 𝑒𝜕 𝑗 𝛻 𝜕 𝑗 𝑜 𝜕 𝑝 p

  10. Advanced Graphics – Path Tracing 10 Path Tracing Direct Illumination We can solve this integral using Monte-Carlo integration: Chose N random directions over the hemisphere for 𝑞  Find the first surface in each direction by tracing a ray  Sum the luminance of the encountered surfaces  Divide the sum by N and multiply by 2π  𝑂 𝑀 𝑝 𝑞, 𝜕 𝑝 ≈ 2𝜌 𝑂 𝑔 𝑠 𝑞, 𝜕 𝑝 , 𝜕 𝑗 𝑀 𝑒 𝑞, 𝜕 𝑗 cos 𝜄 𝑗 𝑗=1 𝜕 𝑗 𝑜 𝜕 𝑝 p

  11. Advanced Graphics – Path Tracing 11 Path Tracing We integrate over the hemisphere, which Direct Illumination has an area of 2 𝜌 . 𝑂 Do not confuse this with the 1/ 𝜌 factor 𝑀 𝑝 𝑞, 𝜕 𝑝 ≈ 2𝜌 in the BRDF, which doesn’t compensate 𝑂 𝑔 𝑠 𝑞, 𝜕 𝑝 , 𝜕 𝑗 𝑀 𝑒 𝑞, 𝜕 𝑗 cos 𝜄 for the surface of the hemisphere, but the 𝑗=1 integral of cos 𝜄 over the hemisphere ( 𝜌 ). Questions:  Why do we multiply by 2𝜌 ?  What is the radiance 𝑀 𝑒 (𝑞, 𝜕 𝑗 ) towards 𝑞 for e.g. a 100W light?  What is the irradiance 𝐹 arriving at 𝑞 from this light? 𝑀 is per sr; 𝑀 𝑒 (𝑞, 𝜕 𝑗 ) is proportional to the solid angle of the light as seen 𝜕 𝑗 from p , so (cos 𝜄 𝑝 𝐵 𝑀 𝑒 )/𝑠 2 . 𝑜 𝜕 𝑝 Note that the 100W flux is spread out over the area; irradiance is defined per 𝑛 2 . p

  12. Advanced Graphics – Path Tracing 12 Path Tracing Direct Illumination 𝑀 𝑝 𝑞, 𝜕 𝑝 = 𝑔 𝑠 𝑞, 𝜕 𝑝 , 𝜕 𝑗 𝑀 𝑒 𝑞, 𝜕 𝑗 cos 𝜄 𝑗 𝑒𝜕 𝑗 𝛻 In many directions, we will not find light sources. We can improve our estimate by sampling the lights separately. 𝑚𝑗𝑕ℎ𝑢𝑡 Here, C compensates for the fact 𝑘 𝑞, 𝜕 𝑗 cos 𝜄 𝑗 𝑒𝜕 𝑗 that we now sample the area of 𝑀 𝑝 𝑞, 𝜕 𝑗 = 𝑔 𝑠 𝑞, 𝜕 𝑝 , 𝜕 𝑗 𝑀 𝑒 the light source, instead of the 𝛻 𝑘=1 hemisphere. The probability of stumbling onto an unoccluded Obviously, sampling the entire hemisphere for each light light used to be proportional to is not necessary; we can sample the area of the light instead: solid angle; now it is always 1. C is therefore ~ (cos 𝜄 𝑝 𝐵 𝑀 𝑒 )/𝑠 2 . 𝑚𝑗𝑕ℎ𝑢𝑡 𝑘 𝑞, 𝜕 𝑗 𝐷 cos 𝜄 𝑗 𝑒𝜕 𝑗 𝑀 𝑝 𝑞, 𝜕 𝑗 = 𝑔 𝑠 𝑞, 𝜕 𝑝 , 𝜕 𝑗 𝑀 𝑒 𝐵 𝑘=1

  13. Advanced Graphics – Path Tracing 13 Path Tracing Direct Illumination 𝑚𝑗𝑕ℎ𝑢𝑡 𝑘 𝑞, 𝜕 𝑗 𝐷 cos 𝜄 𝑗 𝑒𝜕 𝑗 𝑀 𝑝 𝑞, 𝜕 𝑗 = 𝑔 𝑠 𝑞, 𝜕 𝑝 , 𝜕 𝑗 𝑀 𝑒 𝐵 𝑘=1 Using Monte-Carlo: 𝑂 𝑞 ′ 𝐵 𝑀 𝑒 𝑘 cos 𝜄 𝑗 cos 𝜄 𝑝 𝑀 𝑝 𝑞, 𝜕 𝑗 ≈ 𝑚𝑗𝑕ℎ𝑢𝑡 ∗ 1 𝑘 𝑞, 𝑞 ′ 𝑀 𝑒 𝑞 ′ 𝑊 𝑞 ↔ 𝑂 𝑔 𝑠 𝑞, 𝜕 𝑝 , 𝑞′ ∥ 2 ∥ 𝑞 − 𝑗=1 where 𝑘 is the direct light to p from random point 𝑞 ′ on random light  𝑀 𝑒 𝑘  𝐵 𝑀 𝑒 𝑘 is the area of this light source 𝑞 ′ is the mutual visibility between p and p’.  𝑊 𝑞 ↔

  14. Advanced Graphics – Path Tracing 14 Path Tracing Direct Illumination We now have two methods to estimate direct illumination using Monte Carlo integration: 1. By random sampling the hemisphere: 𝑂 𝑀 𝑝 𝑞, 𝜕 𝑝 ≈ 2𝜌 𝑂 𝑔 𝑠 𝑞, 𝜕 𝑝 , 𝜕 𝑗 𝑀 𝑒 𝑞, 𝜕 𝑗 cos 𝜄 𝑗 𝑗=1 2. By sampling the lights directly: 𝑂 𝐵 𝑀 𝑒 𝑘 cos 𝜄 𝑗 cos 𝜄 𝑝 𝑀 𝑝 𝑞, 𝜕 𝑗 ≈ 𝑚𝑗𝑕ℎ𝑢𝑡 ∗ 1 𝑘 𝑞, 𝑞 ′ 𝑀 𝑒 𝑞 ′ 𝑊 𝑞 ↔ 𝑞 ′ 𝑂 𝑔 𝑠 𝑞, 𝜕 𝑝 , 𝑞′ ∥ 2 ∥ 𝑞 − 𝑗=1 For 𝑂 = ∞ , these yield the same result.

  15. Advanced Graphics – Path Tracing 15 Path Tracing Direct Illumination We now have two methods to estimate direct illumination using Monte Carlo integration: 1. By random sampling the hemisphere: 𝑂 𝑀 𝑝 𝑞, 𝜕 𝑝 ≈ 2𝜌 𝑂 𝑔 𝑠 𝑞, 𝜕 𝑝 , 𝜕 𝑗 𝑀 𝑒 𝑞, 𝜕 𝑗 cos 𝜄 𝑗 𝑗=1 2. By sampling the lights directly (three point notation): 𝑂 𝐵 𝑀 𝑒 𝑘 cos 𝜄 𝑗 cos 𝜄 𝑝 𝑀 𝑝 𝑡 ← 𝑞 ≈ 𝑚𝑗𝑕ℎ𝑢𝑡 ∗ 1 𝑘 𝑞 ← 𝑂 𝑔 𝑠 𝑡 ← 𝑞 ← 𝑟 𝑀 𝑒 𝑟 𝑊 𝑞 ↔ 𝑟 𝑟 ∥ 2 ∥ 𝑞 − 𝑗=1 For 𝑂 = ∞ , these yield the same result.

  16. Advanced Graphics – Path Tracing 16 Path Tracing 𝑂 𝑀 𝑝 𝑞, 𝜕 𝑝 ≈ 2𝜌 𝑂 𝑔 𝑠 𝑞, 𝜕 𝑝 , 𝜕 𝑗 𝑀 𝑒 𝑞, 𝜕 𝑗 cos 𝜄 𝑗 𝑗=1 Verification Method 1 in a small C# ray tracing framework: In: Ray ray, with members O, D, N, t. Already calculated: intersection point I = O + t * D. Vector3 R = RTTools.DiffuseReflection( ray.N ); Ray rayToHemisphere = new Ray( I + R * EPSILON, R, 1e34f ); Scene.Intersect( rayToHemisphere ); if (rayToHemisphere.objIdx == LIGHT) { Vector3 BRDF = material.diffuse * INVPI; float cos_i = Vector3.Dot( R, ray.N ); return 2.0f * PI * BRDF * Scene.lightColor * cos_i; }

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend