ray tracing
play

Ray Tracing Graphics & Visualization: Principles & - PowerPoint PPT Presentation

Graphics & Visualization Chapter 15 Ray Tracing Graphics & Visualization: Principles & Algorithms Chapter 15 Introduction Direct-rendering algorithms: Sorting is performed in image space (Z-buffer)


  1. Graphics & Visualization Chapter 15 Ray Tracing Graphics & Visualization: Principles & Algorithms Chapter 15

  2. Introduction • Direct-rendering algorithms:  Sorting is performed in image space (Z-buffer)  Object-to-screen space image synthesizers • Ray tracing is a general algorithm that operates in the opposite manner:  It is a screen-to-object space image synthesizer • In ray tracing , we follow rays along the line of sight passing through each pixel as they travel through the 3-D scene  registers what the observer sees along this direction • As ray encounters geometric entities:  Specularly reflected, refracted, or attenuated (completely absorbed) 2 Graphics & Visualization: Principles & Algorithms Chapter 15

  3. Introduction (2) • Hidden surface elimination happens as part of this process:  Ray encounters surface interfaces closer to the viewer first while it travels through the 3-D world • Simple direct rendering relies on local shading models:  Shadows & reflected/refracted light on surfaces need to be simulated separately & fused as color information in the local illumination model used during scan conversion • Ray tracing, integrates all calculations that involve specular transmission of light in a single & elegant recursive algorithm, the recursive ray tracing algorithm 3 Graphics & Visualization: Principles & Algorithms Chapter 15

  4. Principles of Ray Tracing • Light transmission:  An infinite number of rays emanate from a light source, and a small number reach the eye after following complex paths within the scene • Light is diffusely scattered and specularly reflected or refracted • Part of the specularly & diffusely reflected light is directly received by the observer 4 Graphics & Visualization: Principles & Algorithms Chapter 15

  5. Principles of Ray Tracing (2) • Light reaches the observer indirectly as well:  Following paths through transparent media or by being reflected off perfect mirrors • But:  Given a very large but finite number of rays starting from the light sources, it is statistically unlikely that they will hit the image pixels and contribute to the final result  We must find a different sampling mechanism that ensures that the image pixels are crossed by the light paths and thus adequately sampled 5 Graphics & Visualization: Principles & Algorithms Chapter 15

  6. Principles of Ray Tracing (3) • In ray tracing: Light seen through a pixel of the rendered image is the cumulative contribution of the rays that directly or indirectly hit the surface point visible in this direction and that travel toward the viewpoint • Nearest point encountered by looking at the scene though pixel ( i , j ) in general obstructs all other geometry behind it:  Point may or may not be directly illuminated by the light source(s), depending on whether other geometry prevents the light from reaching it  Paths reaching intersection point from other directions traveling toward pixel ( i , j ) can be followed to discover what light they contribute • This is possible due to the reciprocity of light propagation:  Light follows same path during refraction or perfect reflection on a material interface regardless of the direction of propagation 6 Graphics & Visualization: Principles & Algorithms Chapter 15

  7. Principles of Ray Tracing (4) • If it is directly lit by the light source  local illumination model can be applied • Cumulative illumination visible through a frame-buffer pixel ( i , j ) due to the contribution of direct and indirect rays: 7 Graphics & Visualization: Principles & Algorithms Chapter 15

  8. Principles of Ray Tracing (5) • Since we are only interested in those rays that eventually reach the viewpoint through a viewport pixel  Trace back the light contributions by following the rays in the opposite direction of their propagation toward the source • For each ray back to its source  evaluate the light propagated toward the viewer by applying a local illumination model & re- investigating for other secondary rays that reach that point:  This is exactly the mechanism of ray tracing  A computationally manageable problem 8 Graphics & Visualization: Principles & Algorithms Chapter 15

  9. Principles of Ray Tracing (6) • Compared to direct-rendering algorithms, ray tracing has 2 significant advantages :  Ray-geometry intersections can be directly performed using non- polygonal surfaces, such as geometric solids, implicit or parametric surfaces, and fractals, without requiring any conversion to polygons first  Mathematical surfaces that can be intersected by a ray can be rendered  Reflection & refraction phenomena can be accurately modeled 9 Graphics & Visualization: Principles & Algorithms Chapter 15

  10. Ray Diversion Reflection Refraction 10 Graphics & Visualization: Principles & Algorithms Chapter 15

  11. Reflection ˆ i • For an arbitrary ray of light from a direction incident on a r perfectly reflecting interface between 2 bodies, the reflected ray ˆ r in the perfect mirror-reflection direction is: r (15.1)   ˆ ˆ ˆ ˆ ˆ 2 ( · ) r r n n r r i i • Notice that here the incident direction is the opposite of the light ˆ direction vector since we need to emphasize the direction of l propagation for clarity 11 Graphics & Visualization: Principles & Algorithms Chapter 15

  12. Refraction • Simple index of refraction (or refractive index ) n : Ratio between speed of light c in a vacuum & the phase velocity of light u in this medium:  / n c u (15.2) • n > 1: Transparent materials & n ~ 1: Air • n depends on wavelength λ of the light  n = n ( λ )  For visible light: n ↓ when wavelength  • Phase velocity is responsible for the bending of the propagation direction as the light crosses the interface between them  sin n • According to Snell's law : (15.3)   1 t sin n 2 i  Light entering a medium with larger index of refraction ( n 2 > n 1 ) is bent toward the normal direction of the optically denser medium 12 Graphics & Visualization: Principles & Algorithms Chapter 15

  13. Refraction (2) • When ( n 2 < n 1 ) total internal reflection may occur  Light not transmitted through the boundary but reflected back • Min angle of incidence at which total internal reflection occurs is called a critical angle θ c :   n    2  arcsin (15.4) c   n 1 13 Graphics & Visualization: Principles & Algorithms Chapter 15

  14. Refraction (3) • Calculation of the direction of the new, transmitted ray :      ˆ ˆ ˆ cos si n , (15.5) r n g t t t ˆ ˆ p g r where : unit length vector || and:            ˆ ˆ ˆ ˆ ˆ ˆ ˆ ˆ ˆ ˆ ˆ cos ·( · ) ( ) · r r n r n r n r n r n (15.6) p i i i i i i ˆ i   ˆ r • is a unit vector  length of si n r p i • After normalizing it, we get: ˆ   ˆ ˆ ˆ ˆ r ( · ) r n n r (15.7)   ˆ p i i g   sin s in i i ˆ g • Replacing from (15.7) into (15.5):  sin   (15.8)  ˆ ˆ ˆ ˆ ˆ ˆ t =- cos - ( · )- . r n n nr r  t t i sin i 14 Graphics & Visualization: Principles & Algorithms Chapter 15

  15. Refraction (4) • From (15.3) we can replace the sines in the above relation with the indices of refraction     • Also, using Pythagorean trigonometric identity 2 cos 1 sin t t we get: 2 2   n n            2 2 2 (15.9) 1 1 cos 1 sin 1 sin 1 1 cos t t i i 2 2 n n 2 2 • Introducing these relations in (15.8): 2     n n          ˆ ˆ ˆ ˆ ˆ ˆ 2 1 1 1 1 cos · r n n nr r t i i i 2 (15.10) n n 2 2 • Final step  replace cosine with corresponding inner product:       2 2   n n n n n             2        2 ˆ ˆ ˆ ˆ ˆ ˆ ˆ ˆ ˆ ˆ  ˆ ˆ ˆ ˆ  (15.11) 1 1 1 1 1 1 1 · · · 1 1 · r n n r n n r r r n n r n r   t 2 i i i i i 2 i n n n n n   2 2 2 2 2 15 Graphics & Visualization: Principles & Algorithms Chapter 15

  16. Refraction (5) • Note that quantity inside the radical of (15.11) is > 0:  If < 0  total internal refraction & new ray is calculated from (15.1) • Refracted ray calculation: 16 Graphics & Visualization: Principles & Algorithms Chapter 15

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