MIT EECS 6.837, Durand and Cutler Texture Mapping & Other Fun Stuff.
Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres ›...
Transcript of Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres ›...
![Page 1: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/1.jpg)
MIT EECS 6.837, Durand and Cutler
Acceleration Data Structures for Ray Tracing
![Page 2: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/2.jpg)
MIT EECS 6.837, Durand and Cutler
Today• Review & Schedule• Motivation – Distribution Ray Tracing• Bounding Boxes• Spatial Acceleration Data Structures• Flattening the transformation hierarchy
![Page 3: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/3.jpg)
MIT EECS 6.837, Durand and Cutler
Last Week:• Ray Tracing
– Shadows– Reflection– Refraction
• Local Illumination– Bidirectional Reflectance
Distribution Function (BRDF)
– Phong Model
θiθr
φi φr
![Page 4: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/4.jpg)
MIT EECS 6.837, Durand and Cutler
Schedule• Wednesday October 1st:
Assignment 3 (Ray Tracing & Phong Materials) due
• Sunday October 5th, 5-7 PM,Review Session for Quiz 1
• Tuesday October 7th:Quiz 1: In class
• Wednesday October 15th:Assignment 4 (Grid Acceleration) due
![Page 5: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/5.jpg)
MIT EECS 6.837, Durand and Cutler
Questions?
![Page 6: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/6.jpg)
MIT EECS 6.837, Durand and Cutler
Today• Review & Schedule• Motivation – Distribution Ray Tracing• Bounding Boxes• Spatial Acceleration Data Structures• Flattening the transformation hierarchy
![Page 7: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/7.jpg)
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)
![Page 8: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/8.jpg)
MIT EECS 6.837, Durand and Cutler
Shadows• one shadow ray per
intersection per point light source
no shadow rays
one shadow ray
![Page 9: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/9.jpg)
MIT EECS 6.837, Durand and Cutler
Soft Shadows• multiple shadow rays
to sample area light source
one shadow ray
lots of shadow rays
![Page 10: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/10.jpg)
MIT EECS 6.837, Durand and Cutler
Antialiasing – Supersampling• multiple
rays per pixel
point light
area light
jaggies w/ antialiasing
![Page 11: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/11.jpg)
MIT EECS 6.837, Durand and Cutler
Reflection• one reflection ray per intersection
perfect mirrorθθ
![Page 12: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/12.jpg)
MIT EECS 6.837, Durand and Cutler
Glossy Reflection• multiple reflection
rays
polished surfaceθθ
Courtesy of Justin Legakis. Used with permission.
![Page 13: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/13.jpg)
MIT EECS 6.837, Durand and Cutler
Motion Blur• Sample objects
temporally
Image removed due to copyright considerations.
![Page 14: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/14.jpg)
MIT EECS 6.837, Durand and Cutler
Depth of Field• multiple rays per pixel
focal lengthfilmCourtesy of Justin Legakis. Used with permission.
![Page 15: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/15.jpg)
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?
![Page 16: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/16.jpg)
MIT EECS 6.837, Durand and Cutler
Questions?
![Page 17: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/17.jpg)
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
![Page 18: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/18.jpg)
MIT EECS 6.837, Durand and Cutler
Acceleration of Ray Casting• Goal: Reduce the
number of ray/primitive intersections
![Page 19: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/19.jpg)
MIT EECS 6.837, Durand and Cutler
Conservative Bounding Region• First check for an
intersection with a conservative bounding region
• Early reject
![Page 20: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/20.jpg)
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 → avoidfalse positives
• fast to intersect
![Page 21: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/21.jpg)
MIT EECS 6.837, Durand and Cutler
Intersection with Axis-Aligned BoxFrom Lecture 3,
Ray Casting II• For all 3 axes,
calculate the intersection distances t1 and t2
• tnear = max (t1x, t1y, t1z)tfar = min (t2x, t2y, t2z)
• If tnear> tfar, box is missed
• If tfar< tmin, box is behind
• If box survived tests, report intersection at tnear
y=Y2
y=Y1
x=X1 x=X2
tnear
tfar
t1x
t1y
t2x
t2y
![Page 22: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/22.jpg)
MIT EECS 6.837, Durand and Cutler
Bounding Box of a Triangle
(xmax, ymax, zmax)
(xmin, ymin, zmin)
(x0, y0, z0)
(x1, y1, z1)
(x2, y2, z2)
= (max(x0,x1,x2),max(y0,y1,y2),max(z0,z1,z2))
= (min(x0,x1,x2), min(y0,y1,y2),min(z0,z1,z2))
![Page 23: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/23.jpg)
MIT EECS 6.837, Durand and Cutler
Bounding Box of a Sphere
(xmax, ymax, zmax)
r
(x, y, z)
= (x+r, y+r, z+r)
(xmin, ymin, zmin)= (x-r, y-r, z-r)
![Page 24: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/24.jpg)
MIT EECS 6.837, Durand and Cutler
Bounding Box of a Plane
(xmax, ymax, zmax)= (+∞, +∞, +∞)*
n = (a, b, c)
ax + by + cz = d
(xmin, ymin, zmin)= (-∞, -∞, -∞)*
* unless n is exactly perpendicular to an axis
![Page 25: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/25.jpg)
MIT EECS 6.837, Durand and Cutler
Bounding Box of a Group
(xmax, ymax, zmax)
(xmin_b, ymin_b, zmin_b)
(xmin_a, ymin_a, zmin_a)
(xmax_b, ymax_b, zmax_b)(xmax_a, ymax_a, zmax_a) = (max(xmax_a,xmax_b),
max(ymax_a,ymax_b),max(zmax_a,zmax_b))
(xmin, ymin, zmin) = (min(xmin_a,xmin_b), min(ymin_a,ymin_b),min(zmin_a,zmin_b))
![Page 26: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/26.jpg)
MIT EECS 6.837, Durand and Cutler
Bounding Box of a Transform(x'max, y'max, z'max)
(x'min, y'min, z'min)= (min(x0,x1,x2,x3,x4,x5,x6,x7),
min(y0,y1,y2,y3,y4,x5,x6,x7),min(z0,z1,z2,z3,z4,x5,x6,x7))
M
(xmin, ymin, zmin)(x0,y0,z0) = M (xmin,ymin,zmin)
= (max(x0,x1,x2,x3,x4,x5,x6,x7), max(y0,y1,y2,y3,y4,x5,x6,x7),max(z0,z1,z2,z3,z4,x5,x6,x7))
(x1,y1,z1) = M (xmax,ymin,zmin)
(x2,y2,z2) = M (xmin,ymax,zmin)
(x3,y3,z3) = M (xmax,ymax,zmin)
(xmax, ymax, zmax)
![Page 27: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/27.jpg)
MIT EECS 6.837, Durand and Cutler
Special Case: Transformed TriangleCan we do better?
M
![Page 28: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/28.jpg)
MIT EECS 6.837, Durand and Cutler
Special Case: Transformed Triangle(xmax, ymax, zmax)= (max(x'0,x'1,x'2),
max(y'0,y'1,y'2),max(z'0,z'1,z'2))
M
(xmin, ymin, zmin)= (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 (x0,y0,z0)
(x'1,y'1,z'1) = M (x1,y1,z1) (x'2,y'2,z'2) =
M (x2,y2,z2)
(x2, y2, z2)
(x1, y1, z1)
(x0, y0, z0)
![Page 29: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/29.jpg)
MIT EECS 6.837, Durand and Cutler
Questions?
![Page 30: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/30.jpg)
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
![Page 31: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/31.jpg)
MIT EECS 6.837, Durand and Cutler
Regular Grid
![Page 32: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/32.jpg)
MIT EECS 6.837, Durand and Cutler
Create grid• Find
bounding box of scene
• Choose grid spacing
• gridx need not = gridy
Cell (i, j)
gridy
gridx
![Page 33: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/33.jpg)
MIT EECS 6.837, Durand and Cutler
Insert primitives into grid• Primitives
that overlap multiple cells?
• Insert into multiple cells (use pointers)
![Page 34: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/34.jpg)
MIT EECS 6.837, Durand and Cutler
For each cell along a ray • Does the cell
contain an intersection?
• Yes: return closestintersection
• No: continue
![Page 35: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/35.jpg)
MIT EECS 6.837, Durand and Cutler
Preventing repeated computation• Perform the
computation once, "mark" the object
• Don't re-intersect marked objects
![Page 36: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/36.jpg)
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)
![Page 37: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/37.jpg)
MIT EECS 6.837, Durand and Cutler
Where do we start?• Intersect ray
with scene bounding box
• Ray origin may be insidethe scene bounding box
tmin
tnext_v
tnext_h
tmin
tnext_vtnext_h
Cell (i, j)
![Page 38: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/38.jpg)
MIT EECS 6.837, Durand and Cutler
Is there a pattern to cell crossings?• Yes, the
horizontal and vertical crossings have regular spacing
dtv = gridy / diry
dth = gridx / dirxgridy
gridx
(dirx, diry)
![Page 39: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/39.jpg)
MIT EECS 6.837, Durand and Cutler
What's the next cell?if tnext_v < tnext_h
i += signx
tmin = tnext_v
tnext_v += dtv
elsej += signy
tmin = tnext_h
tnext_h += dth
Cell (i+1, j)
Cell (i, j)
dtvdth
tmin
tnext_v
tnext_h
(dirx, diry)
if (dirx > 0) signx = 1 else signx = -1if (diry > 0) signy = 1 else signy = -1
![Page 40: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/40.jpg)
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
![Page 41: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/41.jpg)
MIT EECS 6.837, Durand and Cutler
Pseudo-codecreate grid insert primitives into gridfor each ray rfind initial cell c(i,j), tmin, tnext_v & tnext_hcompute dtv, dth, signx and signywhile c != NULLfor each primitive p in cintersect r with pif intersection in range foundreturn
c = find next cell
![Page 42: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/42.jpg)
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
![Page 43: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/43.jpg)
MIT EECS 6.837, Durand and Cutler
Questions?
![Page 44: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/44.jpg)
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
![Page 45: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/45.jpg)
MIT EECS 6.837, Durand and Cutler
Adaptive Grids
Nested Grids Octree/(Quadtree)
• Subdivide until each cell contains no more than n elements, or maximum depth d is reached
![Page 46: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/46.jpg)
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)
![Page 47: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/47.jpg)
MIT EECS 6.837, Durand and Cutler
Adaptive Grid Discussion• Advantages?
– grid complexity matches geometric density• Disadvantages?
– more expensive to traverse (especially octree)
![Page 48: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/48.jpg)
MIT EECS 6.837, Durand and Cutler
Bounding Volume Hierarchy• Find bounding box of objects• Split objects into two groups• Recurse
![Page 49: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/49.jpg)
MIT EECS 6.837, Durand and Cutler
Bounding Volume Hierarchy• Find bounding box of objects• Split objects into two groups• Recurse
![Page 50: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/50.jpg)
MIT EECS 6.837, Durand and Cutler
Bounding Volume Hierarchy• Find bounding box of objects• Split objects into two groups• Recurse
![Page 51: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/51.jpg)
MIT EECS 6.837, Durand and Cutler
Bounding Volume Hierarchy• Find bounding box of objects• Split objects into two groups• Recurse
![Page 52: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/52.jpg)
MIT EECS 6.837, Durand and Cutler
Bounding Volume Hierarchy• Find bounding box of objects• Split objects into two groups• Recurse
![Page 53: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/53.jpg)
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
![Page 54: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/54.jpg)
MIT EECS 6.837, Durand and Cutler
Intersection with BVH• Check subvolume with closer intersection first
![Page 55: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/55.jpg)
MIT EECS 6.837, Durand and Cutler
Intersection with BVH• Don't return intersection immediately if the
other subvolume may have a closer intersection
![Page 56: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/56.jpg)
Bounding Volume Hierarchy Discussion
MIT EECS 6.837, Durand and Cutler
• 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
![Page 57: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/57.jpg)
MIT EECS 6.837, Durand and Cutler
Today• Review & Schedule• Motivation – Distribution Ray Tracing• Bounding Boxes• Spatial Acceleration Data Structures• Flattening the transformation hierarchy
![Page 58: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/58.jpg)
MIT EECS 6.837, Durand and Cutler
Transformation Hierarchy• Group & Transformation
hierarchy may not be a good spatial hierarchy
group
group
transform
transform
transform
transform
A C
D E
transformB
group
transformA B
transformC D
transformC E
Flatten
![Page 59: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/59.jpg)
MIT EECS 6.837, Durand and Cutler
Questions?
![Page 60: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/60.jpg)
MIT EECS 6.837, Durand and Cutler
Assignment 4 (due Oct 15th)• 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)
![Page 61: Acceleration Data Structures for Ray Tracingcore.csu.edu.cn › NR › rdonlyres › Electrical... · MIT EECS 6.837, Durand and Cutler Schedule • Wednesday October 1st: Assignment](https://reader035.fdocuments.in/reader035/viewer/2022070815/5f0ea3c77e708231d44035d2/html5/thumbnails/61.jpg)
MIT EECS 6.837, Durand and Cutler
Next Time:
Curves & Surfaces