acceleration data structures for ray tracing
play

Acceleration Data Structures for Ray Tracing Most slides are taken - PowerPoint PPT Presentation

Acceleration Data Structures for Ray Tracing Most slides are taken from Fredo Durand Extra rays needed for these effects: Distribution Ray Tracing Soft shadows Anti-aliasing (getting rid of jaggies) g (g g j gg ) Glossy


  1. Acceleration Data Structures for Ray Tracing Most slides are taken from Fredo Durand

  2. Extra rays needed for these effects: • Distribution Ray Tracing – Soft shadows – Anti-aliasing (getting rid of jaggies) g (g g j gg ) – Glossy reflection – Motion blur Motion blur – Depth of field (focus)

  3. Shadows • one shadow ray per i intersection per point i i light source no shadow rays one shadow ray

  4. Soft Shadows • multiple shadow rays to sample area light l li h source one shadow ray lots of shadow rays

  5. Antialiasing – Supersampling jaggies w/ antialiasing • multiple rays per pixel point light area light g

  6. Reflection • one reflection ray per intersection perfect mirror p θ θ θ θ

  7. Glossy Reflection • multiple reflection rays Justin Legakis Justin Legakis polished surface p θ θ θ θ

  8. Motion Blur • Sample objects temporally ll Rob Cook

  9. Algorithm Analysis • Ray casting cost ≤ height * width * • Lots of primitives num primitives * intersection cost * • Recursive num shadow rays * num shadow rays * • Distributed Ray supersampling * Tracing Effects Tracing Effects num glossy rays * g y y num temporal samples * – Soft shadows max recursion depth * – Anti-aliasing Anti aliasing . . . – Glossy reflection – Motion blur can we reduce this? – Depth of field p

  10. The Ray Tree T 3 T 3 E Eye R 2 N 2 T 1 R R R N 3 3 1 L 1 L 2 N 1 L 3 1 3 L 1 R T 1 1 L L 2 L 3 L N i surface normal Eye R R T 3 R reflected ray R i reflected ray 2 3 L i shadow ray T t T i transmitted (refracted) ray itt d ( f t d)

  11. Questions?

  12. Accelerating Ray Tracing • Four main groups of acceleration techniques: – Reducing the average cost of intersecting a ray with a scene: • Faster intersection calculations • Fewer intersection calculations – Reducing the total number of rays that are traced • Adaptive recursion depth control p p – Discrete Ray Tracing • proximity clouds proximity clouds – Using generalized rays – Parallelization, specialized hardware P ll li ti i li d h d

  13. Acceleration of Ray Casting • Goal: Reduce the number of b f ray/primitive intersections

  14. Bounding Volumes • Idea: associate with each object a simple bounding volume. If a ray misses the bounding volume, it also l If i th b di l it l misses the object contained therein. • Common bounding volumes: – spheres – bounding boxes – bounding slabs • Effective for additional applications: – Clipping acceleration pp g – Collision detection • Note: bounding volumes offer no asymptotic Note: bounding volumes offer no asymptotic improvement!

  15. Conservative Bounding Region • First check for an i intersection with a i i h conservative bounding region • Early reject • Early reject

  16. Conservative Bounding Regions • tight → avoid bounding sphere p false positives • fast to intersect • fast to intersect non-aligned bounding box axis-aligned b bounding box di b arbitrary convex region (bounding half-spaces)

  17. Bounding Volumes

  18. Bounding Boxes can overlap

  19. Intersection with Axis-Aligned Box From Lecture 3, • For all 3 axes, For all 3 axes, Ray Casting II calculate the intersection distances t 1 and t 2 • t near = max ( t 1x , t 1y , t 1z ) t far = min ( t 2x , t 2y , t 2z ) t 2x t far y Y2 y=Y2 • If t near > t far , t 2y box is missed t t nea r t 1x • If t far < t min , box is behind y=Y1 y Y1 • If box survived tests, t 1y report intersection at t near x=X2 x=X1

  20. Bounding Volume Hierarchy • Introduced by James Clark (SGI, Netscape) in 1976 for efficient view-frustum culling. f ffi i i f lli Procedure IntersectBVH(ray, node) ( y, ) begin if IsLeaf(node) then Intersect(ray, node.object) else if IntersectBV(ray,node.boundingVolume) then foreach child of node do IntersectBVH(ray, child) endfor endif end

  21. Bounding Volume Hierarchy • Find bounding box of objects • Split objects into two groups • Recurse • Recurse

  22. Bounding Volume Hierarchy • Find bounding box of objects • Split objects into two groups • Recurse • Recurse

  23. Bounding Volume Hierarchy • Find bounding box of objects • Split objects into two groups • Recurse • Recurse

  24. Bounding Volume Hierarchy • Find bounding box of objects • Split objects into two groups • Recurse • Recurse

  25. Bounding Volume Hierarchy • Find bounding box of objects • Split objects into two groups • Recurse • Recurse

  26. Where to split objects? • At midpoint OR • Sort, and put half of the objects on each side OR • Use modeling hierarchy

  27. Intersection with BVH • Check subvolume with closer intersection first

  28. Intersection with BVH • Don't return intersection immediately if the other subvolume may have a closer intersection h b l h l i i

  29. Questions?

  30. Regular Grid

  31. Create grid • Define grid resolution, not necessarily cubes il b Cell ( i, j ) grid y grid x id

  32. Insert primitives into grid • Primitives that overlap multiple cells? • Insert bbx into multiple cells (use pointers)

  33. For each cell along a ray • Does the cell contain an intersection? • Yes: return closest intersection • No: continue

  34. Preventing repeated computation • Perform the computation once, "mark" the object • Don't re-intersect marked objects

  35. Don't return distant intersections • If intersection t is not within the cell range, continue (there may be something closer) ti (th b thi l )

  36. Where do we start? • Intersect ray Cell ( i j ) Cell ( i, j ) with scene ith bounding box • Ray origin may be inside the scene bounding box t next h next_h t next_v t next_v t min t min t next_h t t t h

  37. Is there a pattern to cell crossings? • Yes, the h horizontal i t l and vertical crossings i dt v = grid y / dir y have regular spacing spacing grid y dt = grid / dir dt h = grid x / dir x ( dir x , dir y ) grid x id

  38. What's the next cell? if t next_v < t next_h Cell ( i+ 1 , j ) i + i += sign x i Cell ( i, j ) t min = t next_v t next_v += dt v d else t next h t next_h j += sign y t next_v t min = t next_h t min t i t next_h += dt h dt dt h dt v ( dir x , dir y ) if (dir > 0) sign = 1 else sign = -1 if (dir x > 0) sign x 1 else sign x -1 if (dir y > 0) sign y = 1 else sign y = -1

  39. What's the next cell? • 3DDDA – Three Di Dimensional Digital i l Di it l Difference Analyzer • We saw this again earlier, for line rasterization

  40. Regular Grid Discussion • Advantages? – easy to construct – easy to traverse y • Disadvantages? Di d t ? – may be only sparsely filled – geometry may still be clumped

  41. Questions?

  42. Adaptive Grids • Subdivide until each cell contains no more than n elements, or maximum depth d is reached l t i d th d i h d N Nested Grids d G id O Octree/(Quadtree) /(Q d )

  43. Primitives in an Adaptive Grid • Can live at intermediate levels, or b be pushed to lowest level of grid h d t l t l l f id O Octree/(Quadtree) /(Q d )

  44. Top down traversal Split ray into sub-segments and traverse each segment recursively. i l

  45. Bottom Up traversal Step from cell to cell. Intersect current cell and add an epsilon into the next cell. il i t th t ll Then search for the cell in the tree. tree. A naïve search starts from the root. Otherwise, try an intelligent guess…

  46. Kd-trees vs. Quad-tree

  47. Kd-trees vs. BSP-tree

  48. Adaptive Spatial Subdivision • Disadvantages of uniform subdivision: – requires a lot of space – traversal of empty regions of space can be slow p y g p – not suitable for “teapot in a stadium” scenes • Solution: use a hierarchical adaptive spatial • Solution: use a hierarchical adaptive spatial subdivision data structure – octrees – BSP-trees • Given a ray, perform a depth-first traversal of the tree Again can stop once an intersection has tree. Again, can stop once an intersection has been found.

  49. Bounding Volume Hierarchy Discussion • Advantages – easy to construct – easy to traverse – binary • Disadvantages – may be difficult to choose a good split for a node – poor split may result in minimal spatial pruning

  50. Uniform vs. Adaptive Subdivision

  51. Macro-regions

  52. Proximity Clouds

  53. Parallel/Distributed RT • Two main approaches: – Each processor is in charge of tracing a subset of the rays. Requires a shared memory architecture, replication of the scene database, or transmission of objects between processors on demand. – Each processor is in charge of a subset of the scene (either in terms of space, or in terms of objects). ( p , j ) Requires processors to transmit rays among themselves.

Recommend


More recommend