Presentation is loading. Please wait.

Presentation is loading. Please wait.

MIT EECS 6.837, Durand and Cutler Acceleration Data Structures for Ray Tracing.

Similar presentations


Presentation on theme: "MIT EECS 6.837, Durand and Cutler Acceleration Data Structures for Ray Tracing."— Presentation transcript:

1 MIT EECS 6.837, Durand and Cutler Acceleration Data Structures for Ray Tracing

2 MIT EECS 6.837, Durand and Cutler Today Review & Schedule Motivation – Distribution Ray Tracing Bounding Boxes Spatial Acceleration Data Structures Flattening the transformation hierarchy

3 MIT EECS 6.837, Durand and Cutler Cool results from Assignment 2 koi seantek

4 MIT EECS 6.837, Durand and Cutler Last Week: Ray Tracing –Shadows –Reflection –Refraction Local Illumination –Bidirectional Reflectance Distribution Function (BRDF) –Phong Model ii rr ii rr

5 MIT EECS 6.837, Durand and Cutler Schedule Wednesday October 1 st : Assignment 3 (Ray Tracing & Phong Materials) due Sunday October 5 th, 5-7 PM, Room TBA: Review Session for Quiz 1 Tuesday October 7 th : Quiz 1: In class Wednesday October 15th: Assignment 4 (Grid Acceleration) due

6 MIT EECS 6.837, Durand and Cutler Questions?

7 MIT EECS 6.837, Durand and Cutler Today Review & Schedule Motivation – Distribution Ray Tracing Bounding Boxes Spatial Acceleration Data Structures Flattening the transformation hierarchy

8 MIT EECS 6.837, Durand and Cutler Extra rays needed for these effects: Distribution Ray Tracing –Soft shadows –Anti-aliasing (getting rid of jaggies) –Glossy reflection –Motion blur –Depth of field (focus)

9 MIT EECS 6.837, Durand and Cutler Shadows one shadow ray per intersection per point light source no shadow rays one shadow ray

10 MIT EECS 6.837, Durand and Cutler Soft Shadows multiple shadow rays to sample area light source one shadow ray lots of shadow rays

11 MIT EECS 6.837, Durand and Cutler Antialiasing – Supersampling multiple rays per pixel point light area light jaggiesw/ antialiasing

12 MIT EECS 6.837, Durand and Cutler one reflection ray per intersection perfect mirror Reflection θ θ

13 MIT EECS 6.837, Durand and Cutler Glossy Reflection multiple reflection rays polished surface θ θ Justin Legakis

14 MIT EECS 6.837, Durand and Cutler Motion Blur Sample objects temporally Rob Cook

15 MIT EECS 6.837, Durand and Cutler Depth of Field multiple rays per pixel Justin Legakis focal length film

16 MIT EECS 6.837, Durand and Cutler Algorithm Analysis Ray casting Lots of primitives Recursive Distributed Ray Tracing Effects –Soft shadows –Anti-aliasing –Glossy reflection –Motion blur –Depth of field cost ≤ height * width * num primitives * intersection cost * num shadow rays * supersampling * num glossy rays * num temporal samples * max recursion depth *... can we reduce this?

17 MIT EECS 6.837, Durand and Cutler Questions?

18 MIT EECS 6.837, Durand and Cutler Today Review & Schedule Motivation – Distribution Ray Tracing Bounding Boxes –of each primitive –of groups –of transformed primitives Spatial Acceleration Data Structures Flattening the transformation hierarchy

19 MIT EECS 6.837, Durand and Cutler Acceleration of Ray Casting Goal: Reduce the number of ray/primitive intersections

20 MIT EECS 6.837, Durand and Cutler Conservative Bounding Region First check for an intersection with a conservative bounding region Early reject

21 MIT EECS 6.837, Durand and Cutler Conservative Bounding Regions axis-aligned bounding box non-aligned bounding box bounding sphere arbitrary convex region (bounding half-spaces) tight → avoid false positives fast to intersect

22 MIT EECS 6.837, Durand and Cutler Intersection with Axis-Aligned Box From Lecture 3, Ray Casting II For all 3 axes, 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 ) If t near > t far, box is missed If t far < t min, box is behind If box survived tests, report intersection at t near y=Y2 y=Y1 x=X1 x=X2 t near t far t 1x t 1y t 2x t 2y

23 MIT EECS 6.837, Durand and Cutler Bounding Box of a Triangle (x min, y min, z min ) (x max, y max, z max ) (x 0, y 0, z 0 ) (x 1, y 1, z 1 ) (x 2, y 2, z 2 ) = (min(x 0,x 1,x 2 ), min(y 0,y 1,y 2 ), min(z 0,z 1,z 2 )) = (max(x 0,x 1,x 2 ), max(y 0,y 1,y 2 ), max(z 0,z 1,z 2 ))

24 MIT EECS 6.837, Durand and Cutler Bounding Box of a Sphere r (x min, y min, z min ) (x max, y max, z max ) (x, y, z) = (x-r, y-r, z-r) = (x+r, y+r, z+r)

25 MIT EECS 6.837, Durand and Cutler Bounding Box of a Plane (x min, y min, z min ) (x max, y max, z max ) = (-∞, -∞, -∞)* = (+∞, +∞, +∞)* n = (a, b, c) ax + by + cz = d * unless n is exactly perpendicular to an axis

26 MIT EECS 6.837, Durand and Cutler Bounding Box of a Group (x min_b, y min_b, z min_b ) (x min, y min, z min ) (x max, y max, z max ) = (min(x min_a,x min_b ), min(y min_a,y min_b ), min(z min_a,z min_b )) = (max(x max_a,x max_b ), max(y max_a,y max_b ), max(z max_a,z max_b )) (x min_a, y min_a, z min_a ) (x max_b, y max_b, z max_b ) (x max_a, y max_a, z max_a )

27 MIT EECS 6.837, Durand and Cutler Bounding Box of a Transform (x' min, y' min, z' min ) (x' max, y' max, z' max ) = (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 0,z 1,z 2,z 3,z 4,x 5,x 6,x 7 )) M (x min, y min, z min ) (x 0,y 0,z 0 ) = M (x min,y min,z min ) = (max(x 0,x 1,x 2,x 3,x 4,x 5,x 6,x 7 ), max(y 0,y 1,y 2,y 3,y 4,x 5,x 6,x 7 ), max(z 0,z 1,z 2,z 3,z 4,x 5,x 6,x 7 )) (x 1,y 1,z 1 ) = M (x max,y min,z min ) (x 2,y 2,z 2 ) = M (x min,y max,z min ) (x 3,y 3,z 3 ) = M (x max,y max,z min ) (x max, y max, z max )

28 MIT EECS 6.837, Durand and Cutler Special Case: Transformed Triangle M Can we do better?

29 MIT EECS 6.837, Durand and Cutler Special Case: Transformed Triangle (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 (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 )) (x' 0,y' 0,z' 0 ) = M (x 0,y 0,z 0 ) (x' 1,y' 1,z' 1 ) = M (x 1,y 1,z 1 ) (x' 2,y' 2,z' 2 ) = M (x 2,y 2,z 2 ) (x 2, y 2, z 2 ) (x 1, y 1, z 1 ) (x 0, y 0, z 0 )

30 MIT EECS 6.837, Durand and Cutler Questions?

31 MIT EECS 6.837, Durand and Cutler Today Review & Schedule Motivation – Distribution Ray Tracing Bounding Boxes Spatial Acceleration Data Structures –Regular Grid –Adaptive Grids –Hierarchical Bounding Volumes Flattening the transformation hierarchy

32 MIT EECS 6.837, Durand and Cutler Regular Grid

33 MIT EECS 6.837, Durand and Cutler Cell (i, j) Create grid Find bounding box of scene Choose grid spacing grid x need not = grid y grid y grid x

34 MIT EECS 6.837, Durand and Cutler Insert primitives into grid Primitives that overlap multiple cells? Insert into multiple cells (use pointers)

35 MIT EECS 6.837, Durand and Cutler For each cell along a ray Does the cell contain an intersection? Yes: return closest intersection No: continue

36 MIT EECS 6.837, Durand and Cutler Preventing repeated computation Perform the computation once, "mark" the object Don't re-intersect marked objects

37 MIT EECS 6.837, Durand and Cutler Don't return distant intersections If intersection t is not within the cell range, continue (there may be something closer)

38 MIT EECS 6.837, Durand and Cutler Where do we start? Intersect ray with scene bounding box Ray origin may be inside the scene bounding box t min t next_v t next_h t min t next_v t next_h Cell (i, j)

39 MIT EECS 6.837, Durand and Cutler Is there a pattern to cell crossings? Yes, the horizontal and vertical crossings have regular spacing dt v = grid y / dir y dt h = grid x / dir x grid y grid x (dir x, dir y )

40 MIT EECS 6.837, Durand and Cutler What's the next cell? dt v dt h Cell (i, j) if t next_v < t next_h i += sign x t min = t next_v t next_v += dt v else j += sign y t min = t next_h t next_h += dt h t min t next_v t next_h Cell (i+1, j) (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

41 MIT EECS 6.837, Durand and Cutler What's the next cell? 3DDDA – Three Dimensional Digital Difference Analyzer We'll see this again later, for line rasterization

42 MIT EECS 6.837, Durand and Cutler Pseudo-code create grid insert primitives into grid for each ray r find initial cell c(i,j), t min, t next_v & t next_h compute dt v, dt h, sign x and sign y while c != NULL for each primitive p in c intersect r with p if intersection in range found return c = find next cell

43 MIT EECS 6.837, Durand and Cutler Regular Grid Discussion Advantages? –easy to construct –easy to traverse Disadvantages? –may be only sparsely filled –geometry may still be clumped

44 MIT EECS 6.837, Durand and Cutler Questions?

45 MIT EECS 6.837, Durand and Cutler Today Review & Schedule Motivation – Distribution Ray Tracing Bounding Boxes Spatial Acceleration Data Structures –Regular Grid –Adaptive Grids –Hierarchical Bounding Volumes Flattening the transformation hierarchy

46 MIT EECS 6.837, Durand and Cutler Adaptive Grids Nested GridsOctree/(Quadtree) Subdivide until each cell contains no more than n elements, or maximum depth d is reached

47 MIT EECS 6.837, Durand and Cutler Primitives in an Adaptive Grid Can live at intermediate levels, or be pushed to lowest level of grid Octree/(Quadtree)

48 MIT EECS 6.837, Durand and Cutler Adaptive Grid Discussion Advantages? –grid complexity matches geometric density Disadvantages? –more expensive to traverse (especially octree)

49 MIT EECS 6.837, Durand and Cutler Bounding Volume Hierarchy Find bounding box of objects Split objects into two groups Recurse

50 MIT EECS 6.837, Durand and Cutler Bounding Volume Hierarchy Find bounding box of objects Split objects into two groups Recurse

51 MIT EECS 6.837, Durand and Cutler Bounding Volume Hierarchy Find bounding box of objects Split objects into two groups Recurse

52 MIT EECS 6.837, Durand and Cutler Bounding Volume Hierarchy Find bounding box of objects Split objects into two groups Recurse

53 MIT EECS 6.837, Durand and Cutler Bounding Volume Hierarchy Find bounding box of objects Split objects into two groups Recurse

54 MIT EECS 6.837, Durand and Cutler Where to split objects? At midpoint OR Sort, and put half of the objects on each side OR Use modeling hierarchy

55 MIT EECS 6.837, Durand and Cutler Intersection with BVH Check subvolume with closer intersection first

56 MIT EECS 6.837, Durand and Cutler Intersection with BVH Don't return intersection immediately if the other subvolume may have a closer intersection

57 MIT EECS 6.837, Durand and Cutler 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

58 MIT EECS 6.837, Durand and Cutler Today Review & Schedule Motivation – Distribution Ray Tracing Bounding Boxes Spatial Acceleration Data Structures Flattening the transformation hierarchy

59 MIT EECS 6.837, Durand and Cutler Transformation Hierarchy group transform A C D E Group & Transformation hierarchy may not be a good spatial hierarchy transform B group transform A B transform C D transform C E Flatten

60 MIT EECS 6.837, Durand and Cutler Questions?

61 MIT EECS 6.837, Durand and Cutler Assignment 4 (due Oct 15 th ) Bounding boxes for primitives Regular grid acceleration data structure Flatten the transformation hierarchy Collect statistics –Average # of rays per pixel –Average # of ray/primitive intersections per pixel Extra Credit: Distribution Ray Tracing (and anything else from past weeks)

62 MIT EECS 6.837, Durand and Cutler Next Time: Curves & Surfaces


Download ppt "MIT EECS 6.837, Durand and Cutler Acceleration Data Structures for Ray Tracing."

Similar presentations


Ads by Google