Lecture 7 - “Path Tracing” Welcome! 푰 풙, 풙′ = 품(풙, 풙′) 흐 풙, 풙′ + 흆 풙, 풙′, 풙′′ 푰 풙′, 풙′′ 풅풙′′ 푺 Today’S Agenda

Lecture 7 - “Path Tracing” Welcome! 푰 풙, 풙′ = 품(풙, 풙′) 흐 풙, 풙′ + 흆 풙, 풙′, 풙′′ 푰 풙′, 풙′′ 풅풙′′ 푺 Today’S Agenda

INFOMAGR – Advanced Graphics Jacco Bikker - November 2016 - February 2017 Lecture 7 - “Path Tracing” Welcome! 푰 풙, 풙′ = 품(풙, 풙′) 흐 풙, 풙′ + 흆 풙, 풙′, 풙′′ 푰 풙′, 풙′′ 풅풙′′ 푺 Today’s Agenda: . Introduction . Path Tracing 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). 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. 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. 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. 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. Today’s Agenda: . Introduction . Path Tracing 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 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 Advanced Graphics – Path Tracing 11 Path Tracing We integrate over the hemisphere, which Direct Illumination has an area of 2휋. 푁 2휋 Do not confuse this with the 1/ 휋 factor 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 2 휔푖 from p, so (cos 휃표 퐴퐿 )/푟 . 푑 휔표 푛 Note that the 100W flux is spread out over the area; irradiance is defined per 푚2. p 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 푗 that we now sample the area of 퐿표 푝, 휔푖 = 푓푟 푝, 휔표, 휔푖 퐿 푝, 휔푖 cos 휃푖 푑휔푖 푑 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 2 is therefore ~(cos 휃표퐴퐿푑)/푟 . 푙푖ℎ푡푠 푗 퐿표 푝, 휔푖 = 푓푟 푝, 휔표, 휔푖 퐿푑 푝, 휔푖 퐶 cos 휃푖 푑휔푖 푗=1 퐴 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’. 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. 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. Advanced Graphics – Path Tracing 16 Path Tracing 푁 2휋 퐿 푝, 휔 ≈ 푓 푝, 휔 , 휔 퐿 푝, 휔 cos 휃 표 표 푁 푟 표 푖 푑 푖 푖 Verification 푖=1 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; } Advanced Graphics – Path Tracing 17 푁 Path Tracing 퐴 cos 휃 cos 휃 1 퐿 푖 표 퐿 푝, 휔 ≈ 푙푔ℎ푡푠 ∗ 푓 푝, 휔 , 푝′ 퐿푗 푝, 푝 ′ 푉 푝 ↔ 푝 ′ 푑 표 푖 푁 푟 표 푑 ∥ 푝 − 푝 ′ ∥2 Verification 푖=1 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, lightNormal ); 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 * lightCount * Scene.lightColor * solidAngle * cos_i; Advanced Graphics – Path Tracing 18 Path Tracing 0.1s Advanced Graphics – Path Tracing 19 Path Tracing 0.5s Advanced Graphics – Path Tracing 20 Path Tracing 2.0s Advanced Graphics – Path Tracing 21 Path Tracing 30.0s Advanced Graphics – Path Tracing 22 Path Tracing Rendering using Monte Carlo Integration In the demonstration, we sampled each light using only 1 sample. The (very noisy) result is directly visualized. To get a better estimate, we average the result of several frames (and thus: several samples). Observations: 1. The light sampling estimator is much better than the hemisphere estimator; 2. Relatively few samples are sufficient for a recognizable image; 3. Noise reduces over time, but we quickly get diminishing returns. Advanced Graphics – Path Tracing 23 Path Tracing Indirect Light Returning to the full rendering equation: We know how to evaluate direct lighting: What remains is indirect light. This is the light that is not emitted by the surface in direction 휔푖, but reflected.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    39 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us