420 likes | 651 Views
Ray Tracing. Chemakura , Baba Kumar Reddy. Introduction to Ray-Tracing. Ray Tracing. global illumination. purpose of Ray Tracing?. Introduction to Ray- Tracing. Basic Setup. Introduction to Ray-tracing. Modeling Rendering. Properties of Light Rays.
E N D
Ray Tracing Chemakura , Baba Kumar Reddy
Introduction to Ray-Tracing • Ray Tracing. global illumination. • purpose of Ray Tracing?
Introduction to Ray- Tracing • Basic Setup
Introduction to Ray-tracing Modeling Rendering
Properties of Light Rays • Light Travels in Straight Lines. • Two Light rays do not interfere with each other if they cross. • Light rays travel from light source to the eye, but physics for path reversal is same.
Light Object Intersection • Reflection v/s Transmission
Light Object Intersection • Specular v/s Diffusion
Types of Ray Tracing • Forward Ray Tracing
Types of Ray Tracing • Backward Ray Tracing
Types of Ray Tracing • Hybrid ray tracing Whitted(1980) Backward Ray tracing + rays to light source
Types of Ray Tracing • Hybrid ray tracing. • Heckbert (1990). backward ray tracing + forward ray tracing + storage on surface. • Veach (1995). backward ray tracing + forward ray tracing + connecting lines.
Ray Tracing Algorithm For( every pixel in the view port) { for(every object in the model world) { if(ray-object intersection) { select the front most intersection; recursively trace the reflection and refraction rays; calculate color; } } }
Practical Considerations in writing a Ray Tracer • Creating Model • Generate primary rays and test for object ray interaction • Shadow Ray • Output file
Intersections • One of the basic routine needed by the ray tracer is an intersection routine for each type of object in the scene: one for spheres, one for cubes , one for cones, one for polygons and so forth. • If ray-object intersections occur, objects intersection routine returns the distance of intersection point from the origin of the ray, the normal vector at the point of intersection and if texture mapping is used , a coordinate mapping between the intersection point and textured image. • Distance is used to choose the closest intersection point. • Normal vector is used to determine the shade at the point, since it describes which direction the surface is faced and therefore how much light the point receives, called cosine shading.
Intersection With Sphere P=point of intersection
Intersection With Sphere V2 + b2 = c2 and d2 + b2 = r2 by simple geometry. And so d = sqrt(r2 – ( c2 - v2 )). If d >= 0 then a valid intersection occurs , if ray does not intersect d < 0. The distance from point of intersection to the origin of ray is v-d, can be found by the following pseudo code. V=dot_product(EO, V). disc=r2 – ((dot_product(EO, EO) -V2 ). If (disc < 0). no intersection. Else. d=sqrt(disc); p=E+(V-d)*V.
Color and Shading and Texture Mapping • Flat Shading. • Cook-Torrance method. • Lambertian Shading / Cosine Shading. computes the angle between the intersection point and the normal vector of the surface, to determine the shading of the surface at that point. Ambient Coefficient, Diffuse Coefficient their importance. • Assigning an entire image to an object instead of a single color is Texture mapping.
Rendering Effects Created by Ray Tracing Shadowing
Rendering Effects Created by Ray Tracing Reflection
Rendering Effects Created by Ray Tracing Transparency
Rendering Effects Created by Ray Tracing Refraction
Precision Problem-the Self Shadowing Problem Passing a flag to the recursive routine to tell a point is on the surface or not. Assuming that all rays start with a tolerance(say 0.000001 inches) of the surface of the primitive shape.
Aliasing • What is Aliasing. • Types of Aliasing. Temporal Aliasing. Due to limitations of eye. Spatial Aliasing. Missing of object falling between two rays. • Anti Aliasing.
Types of Anti-Aliasing Techniques • Super Sampling • Adaptive Super Sampling / Monte-Carlo Sampling • Stochastic Ray Tracing/ Distributed Ray Tracing • Statistical Super sampling
Optimization • Need for Optimization Ray Tracing is computationally intensive process. Eg: The film ToyStory with 110,000 frames, took 46 days to render on 117 Sun Sparc 20’s. • Time taken for Ray tracing Number of Objects x number of rays.
Accelerating Ray Tracing • Use faster machines. • Use specialized hardware, especially parallel processors. • Reduce the total number of rays that need to intersect with the world. • Reduce the number of Ray-Object intersections.
Accelerating Ray Tracing • Reducing the number of rays that hit the world. eg: backward ray tracing, reduces the total number of rays by not considering those that are not captured by the camera.
Acceleration Techniques Overview Ray Tracing Accelerating Techniques Fewer Rays Faster Intersections Generalized Rays Faster Ray Object Intersections Fewer Ray Object Intersections Adaptive Tree Depth Beam Tracing Cone Tracing Pencil Tracing Object Bounding Volumes Efficient intersection routines Bounding volume hierarchies Space sub division Directional techniques
Bounding Volumes Enclosing Groups of objects in sets of bounding volumes and first test for intersection with the bounding volume.
Spatial Subdivision Uniform Non uniform
Spatial Subdivision K-d Tree BSP Tree
Spatial Subdivision • Uniform v/s Non uniform Uniform easier to traverse Non uniform can be faster Non uniform more memory efficient Non Uniform good for scenes where object density varies circle= volumes, squares = objects Uniform spatial subdivision Bounding volume Non uniform spatial subdivision
Issues in Spatial Subdivision • The same ray may test the same object for intersection multiple times.Mailbox? • Need to make sure the intersection occurs in that voxel.
Directional Techniques • Directional Cube : Axis aligned cube with side length=2. (±1 , ±1 , ± 1)
Directional Techniques-Light Buffer • Preprocessing Step to ray tracing, to speed up calculations of shadows. • Form a directional cube around point light. • Candidate lists for each window are formed. • Check for shadows using distance t0
Adaptive Depth Control • Rays are attenuated as they pass through the scene. • Uses properties of materials like reflection coefficient , refraction coefficient and global property like distance attenuation factor.
Generalized Rays • Uses an entire family of rays bundled as beams, cones or pencils • Uses of using these rays are effective antialiasing additional optical effects • Some sacrifices needed are types of primitive objects may need to be restricted the computation of exact intersection needed to be abandoned
Limitations of Ray Tracing • Slow. • Good for ideal environment. • View Dependent. • Not good at rendering in real time. • Alternatives to ray tracing. Ray casting. Radiosity.
Conclusion • Any optimization technique is scene bounded, eg: bounding volumes technique depends upon the density of objects, if more than some threshold use some other method.