welcome today s agenda
play

Welcome! Todays Agenda: Reflections Refraction Recursion - PowerPoint PPT Presentation

INFOGR Computer Graphics Jacco Bikker - April-July 2016 - Lecture 5: Ray Tracing (3) Welcome! Todays Agenda: Reflections Refraction Recursion Shading models TODO INFOGR Lecture 5 Ray Tracing


  1. INFOGR – Computer Graphics Jacco Bikker - April-July 2016 - Lecture 5: “Ray Tracing (3)” Welcome!

  2. Today’s Agenda: Reflections  Refraction  Recursion  Shading models  TODO 

  3. INFOGR – Lecture 5 – “Ray Tracing (3)” 3 Reflections

  4. INFOGR – Lecture 5 – “Ray Tracing (3)” 4 Reflections Light Transport We introduce a pure specular object in the scene. Based on the normal at the primary intersection point, we calculate a new direction. We follow the path using a secondary ray . At the primary intersection point, we ‘see’ what the secondary ray ‘sees’; i.e. the secondary ray behaves like a primary ray. We still need a shadow ray at the new intersection point to establish light transport.

  5. INFOGR – Lecture 5 – “Ray Tracing (3)” 5 Reflections Reflected Vector Reflection: angle of incidence equals angle of reflection . Using normalized vector 𝐸 : 𝐵 = 𝐸 ∙ 𝑂 𝑂 𝐶 = 𝐸 − 𝐵 𝑆 = 𝐶 + (− 𝑶 𝐵) 𝑆 = 𝐸 − 𝑂 𝐸 ∙ 𝑂 − 𝑂(𝐸 ∙ 𝑂) 𝑆 𝐸 𝑺 = 𝑬 − 𝟑(𝑬 ∙ 𝑶)𝑶 𝛽 𝑗 𝛽 𝑝

  6. INFOGR – Lecture 5 – “Ray Tracing (3)” 6 Reflections Light Transport For a pure specular reflection, the energy from a single direction is reflected into a single outgoing direction.  We do not apply 𝑂 ∙ 𝑀  We do apply absorption Since the reflection ray requires the same functionality as a primary ray, it helps to implement this recursively. vec3 Trace( Ray ray ) { I, N, material = scene.GetIntersection( ray ); if (material.isMirror) return material.color * Trace( … ); return DirectIllumination() * material.color; }

  7. INFOGR – Lecture 5 – “Ray Tracing (3)” 7 Reflections What is the color of a bathroom mirror? (In a ray tracer, it’s white.)

  8. INFOGR – Lecture 5 – “Ray Tracing (3)” 8 Reflections Light Transport For pure specular reflections we do not cast a shadow ray. Reason: Light arriving from that direction cannot leave in the direction of the camera.

  9. INFOGR – Lecture 5 – “Ray Tracing (3)” 9 Reflections

  10. INFOGR – Lecture 5 – “Ray Tracing (3)” 10 Reflections Partially Reflective Surfaces We can combine pure specularity and diffuse properties. Situation: our material is only 50% reflective. In this case, we send out the reflected ray, and multiply its yield by 0.5. We also send out a shadow ray to get direct illumination, and multiply the received light by 0.5.

  11. INFOGR – Lecture 5 – “Ray Tracing (3)” 11 Reflections Reflecting a HDR Sky A dark object can be quite bright when reflecting something bright. E.g., a bowling ball, pure specular, color = (0.01, 0.01, 0.01); reflecting a ‘sun’ stored in a HDR skydome, color = (100, 100, 100). For a collection of HDR probes, visit Paul Debevec’s page: http://www.pauldebevec.com/Probes

  12. Today’s Agenda: Reflections  Refraction  Recursion  Shading models  TODO 

  13. INFOGR – Lecture 5 – “Ray Tracing (3)” 13 Refraction Dielectrics Materials such as water and glass require two types of light transport: 1. Transmission 2. Reflection Both of these happen at each medium boundary .

  14. INFOGR – Lecture 5 – “Ray Tracing (3)” 14 Refraction Dielectrics 𝑶 𝐸 The direction of the transmitted vector 𝑈 depends on 𝜄 1 the refraction indices 𝑜 1 , 𝑜 2 of the media separated by the surface. According to Snell’s Law: 𝑜 1 𝑜 1 𝑡𝑗𝑜𝜄 1 = 𝑜 2 𝑡𝑗𝑜𝜄 2 𝑜 2 or 𝑜 1 𝜄 2 𝑡𝑗𝑜𝜄 1 = 𝑡𝑗𝑜𝜄 2 𝑜 2 𝑈 Note: left term may exceed 1, in which case 𝜄 2 cannot be computed. Therefore: 𝑜 1 𝑜 2 𝑡𝑗𝑜𝜄 1 = 𝑡𝑗𝑜𝜄 2 ⟺ 𝑡𝑗𝑜𝜄 1 ≤ 𝑜2 𝑜 2 𝑜1  𝜄 𝑑𝑠𝑗𝑢𝑗𝑑𝑏𝑚 = arcsin 𝑜 1 sin 𝜄 2

  15. INFOGR – Lecture 5 – “Ray Tracing (3)” 15 Refraction Dielectrics 𝑶 𝐸 𝑜 1 𝑜2 𝑜 2 𝑡𝑗𝑜𝜄 1 = 𝑡𝑗𝑜𝜄 2 ⟺ 𝑡𝑗𝑜𝜄 1 ≤ 𝜄 1 𝑜1 𝑜 1 2 𝑜 1 2 𝑙 = 1 − 1 − 𝑑𝑝𝑡𝜄 1 𝑜 2 𝑜 2 𝑈𝐽𝑆, 𝑔𝑝𝑠 𝑙 < 0 𝜄 2 𝑜 1 𝐸 + 𝑂 𝑜 1 𝑈 = 𝑈 𝑑𝑝𝑡𝜄 1 − 𝑙 , 𝑔𝑝𝑠 𝑙 ≥ 0 𝑜 2 𝑜 2 𝑜 1 Note: 𝑑𝑝𝑡𝜄 1 = 𝑂 ∙ −𝐸 , and 𝑜 2 should be calculated only once. * For a full derivation, see http://www.flipcode.com/archives/reflection_transmission.pdf

  16. INFOGR – Lecture 5 – “Ray Tracing (3)” 16 Refraction Dielectrics 𝑶 𝑆 𝐸 A typical dielectric transmits and reflects light. 𝑈

  17. INFOGR – Lecture 5 – “Ray Tracing (3)” 17 Refraction Dielectrics A typical dielectric transmits and reflects light. Based on the Fresnel equations , the reflectivity of the surface for non-polarized light is formulated as: 2 2 1 − 𝑜 1 1 − 𝑜 1 𝑜 1 𝑑𝑝𝑡𝜄 𝑗 − 𝑜 2 𝑜 2 𝑡𝑗𝑜𝜄 𝑗 𝑜 1 𝑑𝑝𝑡𝜄 𝑗 − 𝑜 2 𝑜 2 𝑡𝑗𝑜𝜄 𝑗 𝑠 = 1 𝐺 + 2 2 2 1 − 𝑜 1 1 − 𝑜 1 𝑜 1 𝑑𝑝𝑡𝜄 𝑗 + 𝑜 2 𝑜 2 𝑡𝑗𝑜𝜄 𝑗 𝑜 1 𝑑𝑝𝑡𝜄 𝑗 + 𝑜 2 𝑜 2 𝑡𝑗𝑜𝜄 𝑗

  18. INFOGR – Lecture 5 – “Ray Tracing (3)” 18 Refraction Dielectrics 𝑶 𝑆 𝐸 In practice, we use Schlick’s approximation: 2 𝑜 1 −𝑜 2 𝑠 = 𝑆 0 + (1 − 𝑆 0 )(1 − 𝑑𝑝𝑡𝜄) 5 , where 𝑆 0 = 𝐺 . 𝑜 1 +𝑜 2 Based on the law of conservation of energy: 𝑈 𝐺 𝑢 = 1 − 𝐺 𝑠

  19. Today’s Agenda: Reflections  Refraction  Recursion  Shading models  TODO 

  20. INFOGR – Lecture 5 – “Ray Tracing (3)” 20 Recursion Whitted-style Ray Tracing, Pseudocode Todo: Color Trace( vec3 O, vec3 D )  Implement IntersectScene {  Implement IsVisible I, N, mat = IntersectScene( O, D ); if (!I) return BLACK; return DirectIllumination( I, N ) * mat.diffuseColor; } Color DirectIllumination( vec3 I, vec3 N ) { vec3 L = lightPos – I; float dist = length( L ); L *= (1.0f / dist); if (!IsVisibile( I, L, dist )) return BLACK; float attenuation = 1 / (dist * dist); return lightColor * dot( N, L ) * attenuation; }

  21. INFOGR – Lecture 5 – “Ray Tracing (3)” 21 Recursion Whitted-style Ray Tracing, Pseudocode Todo: Color Trace( vec3 O, vec3 D ) Handle partially { reflective surfaces. I, N, mat = IntersectScene( O, D ); if (!I) return BLACK; if (mat.isMirror()) { return Trace( I, reflect( D, N ) ) * mat.diffuseColor; } else { return DirectIllumination( I, N ) * mat.diffuseColor; } }

  22. INFOGR – Lecture 5 – “Ray Tracing (3)” 22 Recursion Whitted-style Ray Tracing, Pseudocode Todo: Color Trace( vec3 O, vec3 D )  Implement reflect {  Implement refract I, N, mat = IntersectScene( O, D );  Implement Fresnel if (!I) return BLACK;  Cap recursion if (mat.isMirror()) { return Trace( I, reflect( D, N ) ) * mat.diffuseColor; } else if (mat.IsDielectric()) { f = Fresnel( … ); return (f * Trace( I, reflect( D, N ) ) + (1- f) * Trace( I, refract( D, N, … ) ) ) * mat.DiffuseColor; } else { return DirectIllumination( I, N ) * mat.diffuseColor; } }

  23. INFOGR – Lecture 5 – “Ray Tracing (3)” 23 Recursion Spheres: pure specular

  24. INFOGR – Lecture 5 – “Ray Tracing (3)” 24 Recursion Spheres: 50% specular

  25. INFOGR – Lecture 5 – “Ray Tracing (3)” 25 Recursion Spheres: one 50% specular, one glass sphere

  26. INFOGR – Lecture 5 – “Ray Tracing (3)” 26 Recursion

  27. INFOGR – Lecture 5 – “Ray Tracing (3)” 27 Recursion Ray Tree Recursion, multiple light sampling and path splitting in a Whitted-style ray tracer leads to a structure that we refer to as the ray tree . All energy is ultimately transported by a single primary ray. Since the energy does not increase deeper in the tree (on the contrary), the average amount of energy transported by rays decreases with depth.

  28. Today’s Agenda: Reflections  Refraction  Recursion  Shading models  TODO 

  29. INFOGR – Lecture 5 – “Ray Tracing (3)” 29 Shading A diffuse material Diffuse Material appears the same regardless of eye A diffuse material scatters incoming light in all directions. position. 1 Incoming: 𝐹 𝑚𝑗𝑕ℎ𝑢 ∗ 𝑒𝑗𝑡𝑢 2 ∗ 𝑂 ∙ 𝑀 Absorption: 𝐷 𝑛𝑏𝑢𝑓𝑠𝑗𝑏𝑚 Reflection: (𝑊 ∙ 𝑂) terms cancel out. 1 Eye sees: (𝑊∙𝑂) 𝑜

  30. INFOGR – Lecture 5 – “Ray Tracing (3)” 30 Shading Specular Material A specular material reflects light from a particular direction in a single outgoing direction. 𝑂

  31. INFOGR – Lecture 5 – “Ray Tracing (3)” 31 Shading

  32. INFOGR – Lecture 5 – “Ray Tracing (3)” 32 Shading Glossy Material A glossy material reflects most light along the reflected vector. 𝑺 = 𝑴 − 𝟑(𝑴 ∙ 𝑶)𝑶 𝑆 For other directions, the amount of energy is: 𝛽 , where exponent 𝛽 determines 𝑊 ∙ 𝑆 the specularity of the surface. 𝑀 𝑾 𝑂

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