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 Last Time: Graphics Pipeline!! Clipping Line & Polygon Rasterization –Bresenham (DDA) Visibility –Depth Buffer (z-buffer) Modeling Transformations Illumination (Shading) Viewing Transformation (Perspective / Orthographic) Clipping Projection (to Screen Space) Scan Conversion (Rasterization) Visibility / Display

3 MIT EECS 6.837, Durand and Cutler Schedule Wed Oct 13 th Assignment 4 due (Shadows, Reflection, & Refraction) Wed Oct 20 th Assignment 5 due (Voxel Rendering) Review Session for Quiz 1 –Monday 25 th, 7:30 – 9pm, room TBA Tuesday October 26 th, in class: Quiz 1

4 MIT EECS 6.837, Durand and Cutler Today Motivation – Distribution Ray Tracing –Soft shadows –Antialiasing (getting rid of jaggies) –Glossy reflection –Motion blur –Depth of field (focus) Bounding Boxes Spatial Acceleration Data Structures Flattening the Transformation Hierarchy

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

6 MIT EECS 6.837, Durand and Cutler Shadows & Light Sources http://www.pa.uky.edu/~sciworks/light/preview/bulb2.htm clear bulbfrosted bulb http://3media.initialized.org/photos/2000-10-18/index_gall.htm http://www.davidfay.com/index.php

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

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

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

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

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

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

13 MIT EECS 6.837, Durand and Cutler Ray Tracing 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 * size of recursive ray tree * num shadow rays * num supersamples * num glossy rays * num temporal samples * num focal samples *... can we reduce this?

14 MIT EECS 6.837, Durand and Cutler Questions?

15 MIT EECS 6.837, Durand and Cutler Today Motivation – Distribution Ray Tracing Bounding Boxes –of each primitive –of groups –of transformed primitives Spatial Acceleration Data Structures Flattening the Transformation Hierarchy

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

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

18 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

19 MIT EECS 6.837, Durand and Cutler Intersection with Axis-Aligned Box From Lecture 2, 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

20 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 ))

21 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)

22 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

23 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 )

24 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 )

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

26 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 )

27 MIT EECS 6.837, Durand and Cutler Questions?

28 MIT EECS 6.837, Durand and Cutler Today Motivation – Distribution Ray Tracing Bounding Boxes Spatial Acceleration Data Structures –Regular Grid –Adaptive Grids –Hierarchical Bounding Volumes Flattening the Transformation Hierarchy

29 MIT EECS 6.837, Durand and Cutler Regular Grid

30 MIT EECS 6.837, Durand and Cutler Cell (i, j) Create Grid Find bounding box of scene Choose grid resolution (n x, n y, n z ) grid x need not = grid y grid y grid x

31 MIT EECS 6.837, Durand and Cutler Insert Primitives into Grid Primitives that overlap multiple cells? Insert into multiple cells (use pointers)

32 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

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

34 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)

35 MIT EECS 6.837, Durand and Cutler Which Cells Should We Examine? Should we intersect the ray with each voxel? No! we can do better!

36 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_x t next_y t min t next_y t next_x Cell (i, j)

37 MIT EECS 6.837, Durand and Cutler Is there a Pattern to Cell Crossings? Yes, the horizontal and vertical crossings have regular spacing dt x = grid x / dir x dt y = grid y / dir y grid x grid y dir x dir y

38 MIT EECS 6.837, Durand and Cutler What's the Next Cell? dt x dt y Cell (i, j) if ( t next_x < t next_y ) i += sign x t min = t next_x t next_x += dt x else j += sign y t min = t next_y t next_y += dt y t min t next_x t next_y 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

39 MIT EECS 6.837, Durand and Cutler What's the Next Cell? 3DDDA – Three Dimensional Digital Difference Analyzer Similar to Bresenham’s Line Rasterization!

40 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_x & t next_y compute dt x, dt y, 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

41 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

42 MIT EECS 6.837, Durand and Cutler A Note about Typos Typos happen in lecture notes –Don’t be afraid of thinking and asking questions –Please tell us about any typos you find & we’ll fix them ASAP Typos happen in textbooks –The pseudocode for the 3DDDA ray/grid marching in Shirley is buggy –Think, don’t just copy directly

43 MIT EECS 6.837, Durand and Cutler Questions?

44 MIT EECS 6.837, Durand and Cutler Today Motivation – Distribution Ray Tracing Bounding Boxes Spatial Acceleration Data Structures –Regular Grid –Adaptive Grids –Hierarchical Bounding Volumes Flattening the Transformation Hierarchy

45 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

46 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)

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

48 MIT EECS 6.837, Durand and Cutler Today Motivation – Distribution Ray Tracing Bounding Boxes Spatial Acceleration Data Structures –Regular Grid –Adaptive Grids –Hierarchical Bounding Volumes Flattening the Transformation Hierarchy

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 sub-volume 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 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 Assignments 5 & 6 Assignment 5: Voxel Rendering –Bounding boxes for primitives –Sphere voxelization –Regular grid data structure –Fast ray-grid intersection –Flatten the transformation hierarchy Assignment 6: Grid Acceleration & Solid Textures –Accelerated ray tracing (6) –Analyze ray tracing statistics (average # of rays, intersections, etc. per pixel) –Solid textures (next time) –Extra Credit: Distribution Ray Tracing

61 MIT EECS 6.837, Durand and Cutler Ray Marching Visualization primitive density sphere voxelization entered faces cells traversed

62 MIT EECS 6.837, Durand and Cutler Next Time: Texture Mapping


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

Similar presentations


Ads by Google