Ra Tracing Ra-Tracing Illumination Models Local: Depends onl on the model, the light sources and the viewer. Eas to simulate. Eamples: Diffuse and specular illumination models. Flat, Gourard and Phong shading of polhedra. Global: Depends on the entire scene, the light sources and the viewer. Comple to simulate. Eamples: Shadow algorithms, ra-tracing, radiosit methods. Bring the objects to the screen Bring the screen to the objects 3 5 6 Copright Gotsman, Elber, Barequet, Karni, Sheffer Page 1
Ra Tracing 8 9 10 11 1 Copright Gotsman, Elber, Barequet, Karni, Sheffer Page
Ra Tracing 13 14 15 16 17 18 Copright Gotsman, Elber, Barequet, Karni, Sheffer Page 3
Ra Tracing Rendering Equation Ra-Casting Algorithm Ee Image Plane I (, ) g(, )[ e(, ) s(,, ) I(, ) d] Surf Primar Ra 19 0 A Basic Ra-Casting Algorithm RaCast (r, scene) <obj, p> := FirstIntersection(r, scene) if (no obj) return BackgroundColor; else return Shade(p, obj); end; 1 Ra-Object Intersection In the kernel of ever ra-tracer Ra-object intersections are computed millions of times for a single image, hence must be ver efficient Eample: Ra-Sphere intersection ra: ( t) p v t, ( t) p v t, ( t) p v t (unit) sphere: 1 Solve a quadratic equation in t : 0 ( p v t) ( p v t) ( p v t) 1 t ( v v v ) t( p v p v p v ) ( p p p ) 1 p v Ra-Tracing Algorithm Reflection and Refraction Ee Image Plane n Primar Ra Reflected Ra Reflected Ra Snell s law sin 1 c1 sin c n 1 Refracted Ra 3 4 Copright Gotsman, Elber, Barequet, Karni, Sheffer Page 4
Ra Tracing A Basic Ra-Tracing Algorithm RaTrace(r, scene) <obj, p> := FirstIntersection(r, scene) if (no obj) return BackgroundColor; else begin if ( Reflect(obj) ) then ReflectColor := RaTrace(ReflectRa(r, p, obj)); else ReflectColor := Black; if ( Transparent(obj) ) then RefractColor := RaTrace(RefractRa(r, p, obj)); else RefractColor := Black; return Shade(ReflectColor, RefractColor, p, obj); end; Termination in Ra-Tracing Possible termination criteria: No intersection Contribution of secondar ra attenuated below a threshold Maimal depth 5 6 Supersampling Trace multiple primar ras per piel and average their results. 7 8 Optimied Ra-Tracing Basic algorithm is simple but VERY epensive. Optimied ra-tracing is critical Reduce number of ras traced Reduce number of ra-object intersection calculations Methods Bounding Boes Object Hierarchies Spatial Subdivision (Octrees/BSP) Tree Pruning (Randomied) 9 Uniform Spatial Partition 3D space is divided into voels of identical sie. Each voel contains a list of objects it intersects. A tradeoff eists between voel sie and list length. Disadvantage: The subdivision is totall independent of the scene structure. Advantages: Simple! The voels pierced b a ra ma be accessed ver efficientl b incremental calculation. A 3D version of Bresenham's algorithm is used. {C} {A,B} A C B {} 30 Copright Gotsman, Elber, Barequet, Karni, Sheffer Page 5
Ra Tracing Simulating Shadows Simulating Shadows Ee Image Plane Reflected Ra Light Source Trace ra from each ra-object intersection point to light source(s) If no line-of-sight point is shadowed A shadow computation routine: shadow = RaTrace(LightRa(p,obj,light)); to be included in the final shading: return Shade(shadow, ReflectColor, RefractColor, p, obj); Refracted Ra 31 3 33 34 Advanced Phenomena Ra tracers cannot simulate: Soft Shadows Fog Frequenc-dependent light. Snell s law is different for different wave-lengths Indirect light Radiosit is a global scheme complementing ra-tracing that handles S*DS* better 35 36 Copright Gotsman, Elber, Barequet, Karni, Sheffer Page 6
Ra Tracing Radiosit Some VRML Eamples Galler Chamber Models copright Lightscape, Inc. 37 38 40 Museum courtes Computer Graphics Program, Cornell Univ. 41 4 Copright Gotsman, Elber, Barequet, Karni, Sheffer Page 7
Ra Tracing 43 44 45 46 Copright Gotsman, Elber, Barequet, Karni, Sheffer Page 8