CSCI 420 Computer Graphics Lecture 15 Ra Tracing Ra Casting Shadow Ras Reflection and Transmission [Angel Ch. 11] Local Illumination Object illuminations are independent No light scattering between objects No real shadows, reflection, transmission OpenGL pipeline uses this Jernej Barbic Universit of Southern California 1 2 Global Illumination Ra tracing (highlights, reflection, transmission) Radiosit (surface interreflections) Photon mapping Precomputed Radiance Transfer (PRT) Object Space: Graphics pipeline: for each object, render Efficient pipeline architecture, real-time Difficult: object interactions (shadows, reflections, etc.) Image Space: Ra tracing: for each piel, determine color Piel-level parallelism Difficult: ver intensive computation, usuall off-line 3 4 First idea: Forward Ra Tracing Shoot (man) light ras from each light source Ras bounce off the objects Simulates paths of photons Problem: man ras will miss camera and not contribute to! This algorithm is not practical Backward Ra Tracing Shoot one ra from camera through each piel in 5 6 1
Generating Ras Generating Ras Camera is at (0,0,0) and points in the negative -direction Must determine coordinates of corners in 3D field of view angle (fov) center of projection (COP) ra h aspect ratio = w / h w 7 frontal view 8 Generating Ras Generating Ras = tan(fov/2) a = aspect ratio = w / h COP field of view angle (fov) = 0 = 0 f = 1 = -tan(fov/2) 9 = -a tan(fov/2) = tan(fov/2) = -a tan(fov/2) = -tan(fov/2) h w = 0 = 0 frontal view = a tan(fov/2) = tan(fov/2) = a tan(fov/2) = -tan(fov/2) 10 Determining Piel Color 1. Phong model (local as before) 2. Shadow ras 3. Specular reflection 4. Specular transmission Steps (3) and (4) require recursion. Shadow Ras Determine if light reall hits surface point Cast shadow ra from surface point to each light If shadow ra hits opaque object, no contribution from that light This is essentiall improved diffuse reflection light source object 2 shadow ra (blocked) n ra camera object 1 11 12 2
Phong Model If shadow ra can reach to the light, appl a standard Phong model light source shadow ra (unblocked) n l ra camera v object Where is Phong model applied in this eample? Which shadow ras are blocked? 13 14 Reflection Ras For specular component of illumination Compute reflection ra (recall: backward!) Call ra tracer recursivel to determine color Angle of Reflection Recall: incoming angle = outgoing angle r = 2(l n) n l Compute onl for surfaces that are reflective 15 16 Reflections Eample Transmission Ras Calculate light transmitted through surfaces Eample: water, glass Compute transmission ra Call ra tracer recursivel to determine color www.afara.org 17 18 3
Transmitted Light Inde of refraction is speed of light, relative to speed of light in vacuum Vacuum: 1.0 (per definition) Air: 1.000277 (approimate to 1.0) Water: 1.33 Glass: 1.49 Compute t using Snell s law η l = inde for upper material η t = inde for lower material Translucenc Most real objects are not transparent, but blur the background Scatter light on other side of surface Use stochastic sampling (called distributed ra tracing) 19 20 Transmission + Translucenc Eample The Ra Casting Algorithm Simplest case of ra tracing 1. For each piel (,), fire a ra from COP through (,) 2. For each ra & object, calculate closest intersection 3. For closest intersection point p Calculate surface normal For each light source, fire shadow ra For each unblocked shadow ra, evaluate local Phong model for that light, and add the result to piel color Critical operations Ra-surface intersections Illumination calculation www.povra.org 21 22 Recursive Ra Tracing Also calculate specular component Reflect ra from ee on specular surface Transmit ra from ee through transparent surface Determine color of incoming ra b recursion Trace to fied depth Cut off if contribution below threshold Ra Tracing Assessment Global illumination method Image-based Pluses Relativel accurate shadows, reflections, refractions Minuses Slow (per piel parallelism, not pipeline parallelism) Aliasing Inter-object diffuse reflections require man bounces 23 24 4
Ratracing Eample I Ratracing Eample II www.afara.org www.povra.org 25 26 Ratracing Eample III Ratracing Eample IV www.afara.org 27 www.povra.org 28 Summar Ra Casting Shadow Ras and Local Phong Model Reflection Transmission Net lecture: Geometric queries 29 5