welcome

Welcome! , = (, ) , + , , - PowerPoint PPT Presentation

INFOMAGR Advanced Graphics Jacco Bikker - February April 2016 Welcome! , = (, ) , + , , , Todays Agenda:


  1. INFOMAGR – Advanced Graphics Jacco Bikker - February – April 2016 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. A physically based BRDF has some important properties: ο‚§ 𝑔 𝑠 πœ• 𝑝 , πœ• 𝑗 β‰₯ 0 ο‚§ 𝑔 𝑠 πœ• 𝑝 , πœ• 𝑗 = 𝑔 𝑠 πœ• 𝑗 , πœ• 𝑝 𝝏 𝒋 ο‚§ 𝛻 𝑔 𝑠 πœ• 𝑝 , πœ• 𝑗 cos πœ„ 𝑝 π‘’πœ• 𝑝 ≀ 1 𝒐

  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. Path tracing: evaluating this integral using a random walk .

  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? ο‚§ Are we obeying energy conservation? 𝑀 is per sr; 𝑀 𝑒 (π‘ž, πœ• 𝑗 ) is proportional to the solid angle of 𝑀 𝑒 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; }

  17. Advanced Graphics – Path Tracing 17 Path Tracing 𝑂 π‘ž β€² 𝐡 𝑀 𝑒 π‘˜ cos πœ„ 𝑗 cos πœ„ 𝑝 𝑀 𝑝 π‘ž, πœ• 𝑗 β‰ˆ π‘šπ‘—π‘•β„Žπ‘’π‘‘ βˆ— 1 π‘˜ π‘ž, 𝑠 π‘ž, πœ• 𝑝 , π‘ž β€² 𝑀 𝑒 π‘ž β€² π‘Š π‘ž ↔ 𝑂 𝑔 π‘žβ€² βˆ₯ 2 βˆ₯ π‘ž βˆ’ 𝑗=1 Verification Method 2 in a small C# ray tracing framework: // construct vector to random point on light Vector3 L = Scene.RandomPointOnLight() - I; float dist = L.Length(); L /= dist; float cos_o = Vector3.Dot( -L, new Vector3( 0, -1, 0 ) ); float cos_i = Vector3.Dot( L, ray.N ); if ((cos_o <= 0) || (cos_i <= 0)) return BLACK; // light is not behind surface point, trace shadow ray Ray r = new Ray( I + EPSILON * L, L, dist - 2 * EPSILON ); Scene.Intersect( r ); if (r.objIdx != -1) return Vector3.Zero; // light is visible (V(p,p ’)=1); calculate transport Vector3 BRDF = material.diffuse * INVPI; float solidAngle = (cos_o * Scene.LIGHTAREA) / (dist * dist); return BRDF * Scene.lightColor * solidAngle * cos_i;

  18. Advanced Graphics – Path Tracing 18 Path Tracing 0.1s

Recommend


More recommend