ray tracing acceleration
play

Ray-tracing Acceleration Motivation Distribution Ray Tracing - PDF document

Ray-tracing Acceleration Motivation Distribution Ray Tracing Soft shadows Acceleration Data Structures Antialiasing (getting rid of jaggies) for Ray Tracing Glossy reflection Motion blur Depth of field (focus)


  1. Ray-tracing Acceleration • Motivation – Distribution Ray Tracing – Soft shadows Acceleration Data Structures – Antialiasing (getting rid of jaggies) for Ray Tracing – Glossy reflection – Motion blur – Depth of field (focus) • Bounding Boxes Thanks to Fredo Durand and Barb Cutler • Spatial Acceleration Data Structures • Flattening the Transformation Hierarchy Shadows Shadows & Light Sources • one shadow ray per intersection per point light source no shadow rays http://www.davidfay.com/index.php clear bulb frosted bulb http://3media.initialized.org/photos/2000-10-18/index_gall.htm http://www.pa.uky.edu/~sciworks/light/preview/bulb2.htm one shadow ray Soft Shadows Antialiasing – Supersampling • Multiple shadow rays to • Multiple rays jaggies w/ antialiasing sample area light source per pixel • Distribute rays over an • Distribute rays interval – light source over an interval – multiple rays per pixel one shadow ray point light area light lots of shadow rays 1

  2. Reflection Glossy Reflection • one reflection ray per intersection • multiple reflection rays • Distribute rays over an interval – multiple reflection rays Justin Legakis perfect mirror polished surface θ θ θ θ Motion Blur Depth of Field • Sample objects • Distribute rays over temporally an interval - lens area • Distribute rays over an interval - time Rob Cook film focal length Justin Legakis Ray Tracing Algorithm Analysis Ray-Tracing Taxonomy • Ray casting cost ≈ height * width * • Lots of primitives num primitives * intersection cost * • Recursive size of recursive ray tree * • Distributed Ray num shadow rays * Tracing Effects num supersamples * num glossy rays * – Soft shadows num temporal samples * – Anti-aliasing num focal samples * . . . – Glossy reflection – Motion blur can we reduce this? by James Arvo and David Kirk – Depth of field 2

  3. Ray-tracing Acceleration Acceleration of Ray Casting • Motivation – Distribution Ray Tracing • Goal: Reduce the number of • Bounding Boxes ray/primitive – of each primitive intersections – of groups – of transformed primitives • Spatial Acceleration Data Structures • Flattening the Transformation Hierarchy Conservative Bounding Region Conservative Bounding Regions • First check for an • tight → avoid bounding sphere intersection with a false positives conservative • fast to intersect bounding region • Early reject non-aligned bounding box axis-aligned bounding box arbitrary convex region (bounding half-spaces) Intersection with Axis-Aligned Box Bounding Box of a Triangle • For all 3 axes, ( x max , y max , z max ) ( x 0 , y 0 , z 0 ) calculate the intersection = (max( x 0 ,x 1 ,x 2 ), distances t 1 and t 2 max( y 0 ,y 1 ,y 2 ), • t near = max ( t 1x , t 1y , t 1z ) max( z 0 ,z 1 ,z 2 )) t 2x t far = min ( t 2x , t 2y , t 2z ) ( x 1 , y 1 , z 1 ) t far y=Y2 • If t near > t far , t 2y box is missed t nea r t 1x • If t far < t min , ( x 2 , y 2 , z 2 ) ( x min , y min , z min ) box is behind y=Y1 • If box survived tests, = (min( x 0 ,x 1 ,x 2 ), t 1y report intersection at t near min( y 0 ,y 1 ,y 2 ), x=X2 x=X1 min( z 0 ,z 1 ,z 2 )) 3

  4. Bounding Box of a Sphere Bounding Box of a Plane ( x max , y max , z max ) ( x max , y max , z max ) = ( + ∞ , + ∞ , + ∞ )* = ( x+r, y+r, z+r ) r n = ( a, b, c ) ( x, y, z ) ax + by + cz = d ( x min , y min , z min ) ( x min , y min , z min ) = ( x-r, y-r, z-r ) = ( - ∞ , - ∞ , - ∞ )* * unless n is exactly perpendicular to an axis Bounding Box of a Group Bounding Box of a Transform ( x' max , y' max , z' max ) ( x max , y max , z max ) = (max( x 0 ,x 1 ,x 2 ,x 3 ,x 4 ,x 5 ,x 6 ,x 7 ), ( x max_a , y max_a , z max_a ) = (max( x max_a ,x max_b ), max( y 0 ,y 1 ,y 2 ,y 3 ,y 4 ,x 5 ,x 6 ,x 7 ), ( x max , y max , z max ) ( x max_b , y max_b , z max_b ) max( z 0 ,z 1 ,z 2 ,z 3 ,z 4 ,x 5 ,x 6 ,x 7 )) max( y max_a ,y max_b ), max( z max_a ,z max_b )) M ( x 3 ,y 3 ,z 3 ) = M ( x max ,y max ,z min ) ( x min_b , y min_b , z min_b ) ( x 2 ,y 2 ,z 2 ) = ( x 1 ,y 1 ,z 1 ) = M ( x min ,y max ,z min ) M ( x max ,y min ,z min ) ( x min_a , y min_a , z min_a ) ( x 0 ,y 0 ,z 0 ) = ( x min , y min , z min ) = (min( x min_a ,x min_b ), ( x' min , y' min , z' min ) M ( x min ,y min ,z min ) ( x min , y min , z min ) min( y min_a ,y min_b ), = (min( x 0 ,x 1 ,x 2 ,x 3 ,x 4 ,x 5 ,x 6 ,x 7 ), min( y 0 ,y 1 ,y 2 ,y 3 ,y 4 ,x 5 ,x 6 ,x 7 ), min( z min_a ,z min_b )) min( z 0 ,z 1 ,z 2 ,z 3 ,z 4 ,x 5 ,x 6 ,x 7 )) Special Case: Transformed Triangle Special Case: Transformed Triangle Can we do better? ( x max , y max , z max ) = (max( x' 0 ,x' 1 ,x' 2 ), max( y' 0 ,y' 1 ,y' 2 ), max( z' 0 ,z' 1 ,z' 2 )) M M ( x 0 , y 0 , z 0 ) ( x' 0 ,y' 0 ,z' 0 ) = M ( x 0 ,y 0 ,z 0 ) ( x 1 , y 1 , z 1 ) ( x' 1 ,y' 1 ,z' 1 ) = ( x' 2 ,y' 2 ,z' 2 ) = M ( x 1 ,y 1 ,z 1 ) M ( x 2 ,y 2 ,z 2 ) ( x 2 , y 2 , z 2 ) ( x min , y min , z min ) = (min( x' 0 ,x' 1 ,x' 2 ), min( y' 0 ,y' 1 ,y' 2 ), min( z' 0 ,z' 1 ,z' 2 )) 4

  5. Ray-tracing Acceleration Regular Grid • Motivation – Distribution Ray Tracing • Bounding Boxes • Spatial Acceleration Data Structures – Regular Grid – Adaptive Grids – Hierarchical Bounding Volumes • Flattening the Transformation Hierarchy Create Grid Insert Primitives into Grid • Find bounding • Primitives box of scene that overlap Cell ( i, j ) multiple • Choose grid cells? resolution ( n x , n y , n z ) • Insert into multiple • grid x need cells (use not = grid y pointers) grid y grid x For Each Cell Along a Ray Preventing Repeated Computation • Does the cell • Perform the contain an computation intersection? once, "mark" the object • Yes: return closest • Don't intersection re-intersect marked • No: continue objects 5

  6. Don't Return Distant Intersections Which Cells Should We Examine? • If intersection • Should we intersect t is not within the ray with the cell range, each voxel? continue • No! we can (there may be do better! something closer) Where Do We Start? Is there a Pattern to Cell Crossings? • Intersect ray • Yes, the with scene horizontal Cell ( i, j ) bounding box and vertical crossings • Ray origin have regular dt x = grid x / dir x may be inside spacing the scene bounding box t next_y t next_x t min t next_y grid y dir y dt y = grid y / dir y t next_x t min dir x grid x What's the Next Cell? What's the Next Cell? • 3DDDA – Three if ( t next_x < t next_y ) Cell ( i+ 1 , j ) Dimensional Digital i += sign x Cell ( i, j ) Difference Analyzer t min = t next_x t next_x += dt x else • Similar to t next_y j += sign y Bresenham’s t next_x Line Rasterization! t min = t next_y t min t next_y += dt y dt y dt x ( dir x , dir y ) if (dir x > 0) sign x = 1 else sign x = -1 if (dir y > 0) sign y = 1 else sign y = -1 6

  7. Pseudo-Code Regular Grid Discussion • Advantages? create grid insert primitives into grid – easy to construct for each ray r – easy to traverse find initial cell c(i,j), t min , t next_x & t next_y compute dt x , dt y , sign x and sign y • Disadvantages? while c != NULL for each primitive p in c – may be only sparsely filled intersect r with p – geometry may still be clumped if intersection in range found return c = find next cell Ray-tracing Acceleration Adaptive Grids • Motivation – Distribution Ray Tracing • Subdivide until each cell contains no more than n elements, or maximum depth d is reached • Bounding Boxes • Spatial Acceleration Data Structures – Regular Grid – Adaptive Grids – Hierarchical Bounding Volumes • Flattening the Transformation Hierarchy Nested Grids Octree/(Quadtree) Primitives in an Adaptive Grid Adaptive Grid Discussion • Can live at intermediate levels, or • Advantages? be pushed to lowest level of grid – grid complexity matches geometric density • Disadvantages? – more expensive to traverse (especially octree) Octree/(Quadtree) 7

  8. Ray-tracing Acceleration Bounding Volume Hierarchy • Motivation – Distribution Ray Tracing • Find bounding box of objects • Bounding Boxes • Split objects into two groups • Spatial Acceleration Data Structures • Recurse – Regular Grid – Adaptive Grids – Hierarchical Bounding Volumes • Flattening the Transformation Hierarchy Bounding Volume Hierarchy Bounding Volume Hierarchy • Find bounding box of objects • Find bounding box of objects • Split objects into two groups • Split objects into two groups • Recurse • Recurse Bounding Volume Hierarchy Bounding Volume Hierarchy • Find bounding box of objects • Find bounding box of objects • Split objects into two groups • Split objects into two groups • Recurse • Recurse 8

Recommend


More recommend