cs 636 advanced rendering techniquesdavid/classes/cs636/lectures/cs636_pr… · cs 636 advanced...
TRANSCRIPT
![Page 1: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/1.jpg)
CS 636 Advanced Rendering Techniques
Dr. David BreenOnlineWednesday 6PM ® 8:50PM
Presentation 34/22/20
![Page 2: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/2.jpg)
Questions from Last Week?n Color modelsn Light modelsn Phong shading modeln Assignment 2
![Page 3: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/3.jpg)
Slide Credits
n Leonard McMillan, Seth Teller, Fredo Durand, Barb Cutler - MIT
n David Luebke - University of Virginian Matt Pharr - Stanford Universityn Jonathan Cohen - Johns Hopkins U.n Kevin Suffern -University of Technology,
Sydney, Australia
![Page 4: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/4.jpg)
More Geometry & Intersections
![Page 5: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/5.jpg)
Ray/Plane IntersectionRay is defined by R(t) = Ro + Rd*t where t ³ 0
Ro = Origin of ray at (xo, yo, zo)Rd = Direction of ray [xd, yd, zd] (unit vector)
Plane is defined by [A, B, C, D]Ax + By + Cz + D = 0 for a point in the planeNormal Vector, N = [A, B, C] (unit vector)A2 + B2 + C2 = 1D = - N • P0 (P0 - point in plane)
![Page 6: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/6.jpg)
Ray/Plane (cont.)Substitute the ray equation into the plane equation:
A(xo + xdt) + B(yo + ydt) + C(zo +zdt) + D = 0
Solve for t:t = -(Axo + Byo + Czo + D) / (Axd + Byd + Czd)t = -(N • Ro - N • P0 ) / (N • Rd)First check that N • Rd not equal to zero!
![Page 7: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/7.jpg)
What Can Happen?N • Rd = 0 N • Rd > 0
t < 0
Ro
t > 0
Ro
![Page 8: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/8.jpg)
Ray/Plane SummaryIntersection point:
(xi, yi, zi) = (xo + xdti, yo + ydti, zo + zdti)
1. Calculate N • Rd and compare it to zero.2. Calculate ti and compare it to zero.3. Compute intersection point.4. Flip normal if N • Rd is positive
![Page 9: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/9.jpg)
Ray-Parallelepiped Intersection
n Axis-alignedn From (X1, Y1, Z1) to (X2, Y2, Z2)n Ray P(t)=Ro+Rdt
y=Y2
y=Y1
x=X1 x=X2
Ro
Rd
![Page 10: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/10.jpg)
Naïve ray-box Intersectionn Use 6 plane equationsn Compute all 6 intersectionn Check that points are inside boxn The sign of Ax+By+Cz+D tells you if point is
above or below the planey=Y2
y=Y1
x=X1 x=X2
Ro
Rd
![Page 11: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/11.jpg)
Factoring out computation
n Pairs of planes have the same normaln Normals have only one non-0 componentn Do computations one dimension at a timen Maintain tnear and tfar (closest and farthest so
far)y=Y2
y=Y1
x=X1 x=X2
Ro
Rd
![Page 12: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/12.jpg)
Test if parallel
n If Rdx = 0, then ray is paralleln If Rox < X1 or Rox > x2 return false
y=Y2
y=Y1
x=X1 x=X2
Ro
Rd
![Page 13: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/13.jpg)
If not paralleln Calculate intersection distance t1 and t2
n t1 = (X1-Rox)/Rdxn t2 = (X2-Rox)/Rdx
y=Y2
y=Y1
x=X1 x=X2
Ro
Rd
t1
t2
![Page 14: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/14.jpg)
Test 1n Maintain tnear and tfar
n If t1 > t2, swapn if t1 > tnear, tnear = t1 n if t2 < tfar, tfar = t2
n If tnear > tfar, box is missed
y=Y2
y=Y1
x=X1 x=X2
RoRd
t1x t2xtnear
t1y
t2ytfar
tfar
![Page 15: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/15.jpg)
Test 2n If tfar < 0, box is behind
y=Y2
y=Y1
x=X1 x=X2
Ro
Rd
t1xt2xtfar
![Page 16: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/16.jpg)
Algorithm recapn Do for all 3 axes
n Calculate intersection distance t1 and t2n Maintain tnear and tfarn If tnear > tfar, box is missed; Donen If tfar < 0, box is behind; Done
n If box survived tests, return intersection at tnearn If tnear is negative, return tfar
y=Y2
y=Y1
x=X1 x=X2RoRd
tnear
t1y
tfar
![Page 17: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/17.jpg)
Motivation
![Page 18: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/18.jpg)
Extra rays needed for these effectsn Distributed Ray Tracing
n Soft shadowsn Anti-aliasing (getting rid of jaggies)n Glossy reflectionn Motion blurn Depth of field (focus)
![Page 19: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/19.jpg)
Shadowsn one shadow ray per
intersection per point light source no shadow rays
one shadow ray
![Page 20: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/20.jpg)
Soft Shadowsn multiple shadow rays
to sample area light source one shadow ray
lots of shadow rays
![Page 21: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/21.jpg)
Antialiasing – Supersamplingn multiple
rays per pixel
point light
area light
jaggies w/ antialiasing
![Page 22: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/22.jpg)
n one reflection ray per intersection
perfect mirror
Reflection
θθ
![Page 23: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/23.jpg)
Glossy Reflectionn multiple reflection rays
polished surfaceθθ
Justin Legakis
![Page 24: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/24.jpg)
Motion Blurn Sample
objects temporally
Rob Cook
![Page 25: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/25.jpg)
Depth of Fieldn multiple rays per pixel
Justin Legakisfocal lengthfilm
![Page 26: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/26.jpg)
Algorithm Analysisn Ray castingn Lots of primitivesn Recursiven Distributed Ray
Tracing Effectsn Soft shadowsn Anti-aliasingn Glossy reflectionn Motion blurn 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 27: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/27.jpg)
![Page 28: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/28.jpg)
Bounding Regions
![Page 29: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/29.jpg)
Acceleration of Ray Castingn Goal: Reduce the
number of ray/primitive intersection tests
![Page 30: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/30.jpg)
Conservative Bounding Regionn First check for an
intersection with a conservative bounding region
n Early reject
![Page 31: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/31.jpg)
Conservative Bounding Regionsbounding
sphere
axis-aligned bounding box
arbitrary convex region (bounding half-spaces)
non-aligned bounding box
• tight ® avoidfalse positives
• fast to compute
• fast to intersect
![Page 32: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/32.jpg)
Bounding Volumesn What makes a “good” bounding volume?
n Tightness of fit (expressed how?)n Easy to computen Simplicity of intersection n Total cost = b*B + i*I +S
• b: # times volume tested for intersection• B: cost of ray-volume intersection test• i: # times item is tested for intersection• I: cost of ray-item intersection test• S: cost to compute BV parameters
![Page 33: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/33.jpg)
![Page 34: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/34.jpg)
![Page 35: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/35.jpg)
Bounding Volumesn Spheres
n Cheap intersection testn Poor fit n Somewhat costly
to fit to data
bounding sphere
![Page 36: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/36.jpg)
Bounding Volumesn Axis-aligned bounding boxes (AABBs)
n Relatively cheap intersection testn Usually better fitn Trivial to fit to data
axis-aligned bounding box
![Page 37: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/37.jpg)
Bounding Volumesn Oriented bounding boxes (OBBs)
n Medium-expensive intersection testn Very good fit (asymptotically better)n Medium-difficult to fit to data
oriented bounding box
![Page 38: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/38.jpg)
Bounding Volumesn Slabs (parallel planes)
n Comparatively expensiven Very good fitn Very difficult to fit to
data
arbitrary convex region (bounding half-spaces)
![Page 39: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/39.jpg)
Intersection with Axis-Aligned Box
n For all 3 axes, calculate the intersection distances t1 and t2
n tnear = max (t1x, t1y, t1z)tfar = min (t2x, t2y, t2z)
n If tnear> tfar, box is missed
n If tfar< 0, box is behind
n If box survived tests, report intersection at tnear
y=Y2
y=Y1
x=X1 x=X2
tnear
tfar
t1x
t1y
t2x
t2y
![Page 40: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/40.jpg)
Bounding Box of a Triangle
(xmin, ymin, zmin)
(x0, y0, z0)
(x1, y1, z1)
(x2, y2, z2)= (min(x0,x1,x2), min(y0,y1,y2),min(z0,z1,z2))
(xmax, ymax, zmax)= (max(x0,x1,x2),
max(y0,y1,y2),max(z0,z1,z2))
![Page 41: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/41.jpg)
Bounding Box of a Sphere
r
(x, y, z)
(xmin, ymin, zmin)= (x-r, y-r, z-r)
(xmax, ymax, zmax)
= (x+r, y+r, z+r)
![Page 42: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/42.jpg)
Bounding Box of a Group
(xmin, ymin, zmin) = (min(xmin_a,xmin_b), min(ymin_a,ymin_b),min(zmin_a,zmin_b))
(xmax, ymax, zmax)= (max(xmax_a,xmax_b),
max(ymax_a,ymax_b),max(zmax_a,zmax_b))
(xmin_b, ymin_b, zmin_b)
(xmin_a, ymin_a, zmin_a)
(xmax_b, ymax_b, zmax_b)(xmax_a, ymax_a, zmax_a)
![Page 43: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/43.jpg)
Acceleration Spatial Data Structures
![Page 44: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/44.jpg)
Spatial Data Structuresn Spatial partitioning techniques classify all space into
non-overlapping portionsn Easier to generate automaticallyn Can “walk” ray from partition to partition
n Hierarchical bounding volumes surround objects in the scene with (possibly overlapping) volumesn Often tightest fit
![Page 45: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/45.jpg)
Spatial Partitioningn Some spatial partitioning schemes:
n Regular grid (2-D or 3-D)n Octreen k-D treen BSP-tree
![Page 46: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/46.jpg)
Acceleration Spatial Data Structures
Regular Grid
![Page 47: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/47.jpg)
Regular Grid
![Page 48: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/48.jpg)
Create gridn Find
bounding box of scene
n Choose grid spacing
n gridx need not = gridy
Cell (i, j)
gridy
gridx
![Page 49: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/49.jpg)
Insert primitives into gridn Primitives
that overlap multiple cells?
n Insert into multiple cells (use pointers)
![Page 50: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/50.jpg)
n Does the cell contain an intersection?
n Yes: return closestintersection
n No: continuen Use
algorithm to step through cells
For each cell along a ray
![Page 51: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/51.jpg)
Preventing repeated computationn Perform the
computation once, "mark" the object
n Don't re-intersect marked objects
![Page 52: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/52.jpg)
n If intersection t is not within the cell range, continue (there may be something closer)
Don't return distant intersections
![Page 53: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/53.jpg)
Where do we start?n Intersect ray
with scene bounding box
n Ray origin may be inside the scene bounding box
tmin
tnext_v
tnext_h
tmin
tnext_vtnext_h
Cell (i, j)
![Page 54: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/54.jpg)
Is there a pattern to cell crossings?n Yes, the
horizontal and vertical crossings have regular spacing
dtv = gridy / diry
dth = gridx / dirxgridy
gridx
(dirx, diry)
![Page 55: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/55.jpg)
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 dtvdth
Cell (i, j)
tmin
tnext_v
tnext_h
Cell (i+1, j)
(dirx, diry)
if (dirx > 0) signx = 1 else signx = -1if (diry > 0) signy = 1 else signy = -1
![Page 56: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/56.jpg)
What's the next cell? n 3DDDA – Three
Dimensional Digital Difference Analyzer
n 3D Bresenham Algorithm
![Page 57: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/57.jpg)
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 58: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/58.jpg)
Regular Grid Discussion
n Advantages?n easy to constructn easy to traverse
n Disadvantages?n may be only sparsely filledn geometry may still be clumped in a small
number of cells
![Page 59: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/59.jpg)
Acceleration Spatial Data Structures
Adaptive Grids
![Page 60: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/60.jpg)
Adaptive Grids
Nested Grids Octree/(Quadtree)
n Subdivide until each cell contains no more than n elements, or maximum depth d is reached
![Page 61: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/61.jpg)
Primitives in an Adaptive Gridn Can live at intermediate levels, or
be pushed to lowest level of grid
Octree/(Quadtree)
![Page 62: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/62.jpg)
Adaptive Grid Discussionn Advantages?
n grid complexity matches geometric densityn Disadvantages?
n more expensive to traverse (especially octree)
![Page 63: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/63.jpg)
k-D Treesn k-D tree pros:
n Moderately simple to generaten More adaptive than octrees
n k-D tree cons:n Less efficient to trace rays
acrossn Moderately complex data
structure
![Page 64: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/64.jpg)
BSP Treesn BSP tree pros:
n Extremely adaptiven Simple & elegant data
structuren BSP tree cons:
n Very hard to create optimal BSP
n Splitting planes can explode storage
n Simple but slow to trace rays across
![Page 65: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/65.jpg)
Acceleration Spatial Data Structures
Bounding Volume Hierarchy
![Page 66: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/66.jpg)
Bounding Volume Hierarchyn What makes a “good” bounding volume
hierarchy?n Grouped objects (or volumes) should be near
each othern Volume should be minimaln Sum of all volumes should be minimaln Top of the tree is most criticaln Constructing the hierarchy should pay for
itself!
![Page 67: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/67.jpg)
Bounding Volume Hierarchyn Find bounding box of objectsn Split objects into two groupsn Recurse
![Page 68: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/68.jpg)
Bounding Volume Hierarchyn Find bounding box of objectsn Split objects into two groupsn Recurse
![Page 69: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/69.jpg)
Bounding Volume Hierarchyn Find bounding box of objectsn Split objects into two groupsn Recurse
![Page 70: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/70.jpg)
Bounding Volume Hierarchyn Find bounding box of objectsn Split objects into two groupsn Recurse
![Page 71: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/71.jpg)
Bounding Volume Hierarchyn Find bounding box of objectsn Split objects into two groupsn Recurse
![Page 72: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/72.jpg)
Where to split objects?n At midpoint ORn Sort, and put half of the objects on each side ORn Use modeling hierarchy
![Page 73: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/73.jpg)
Data Structure Pseudo-codesort_axis = 0;Make_BVH(object_list, sort_axis, ptr)
struct.bbox = BoundingBox(object_list);If # of objects < Threshold
struct.obj_list = object_listElse
If ((sort_axis % 3)== 0) Sort object centroids in XElseIf ((sort_axis % 3)== 1)
Sort object centroids in YElse
Sort object centroids in ZSplit sorted list into two halvesMake_BVH(left_obj_list, sort_axis++, lptr)Make_BVH(right_obj_list, sort_axis++, rptr)struct.lptr = lptr; struct.rptr = rptr;
ptr = &struct;
Return
![Page 74: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/74.jpg)
Intersection with BVHn Check subvolume with closer intersection first
![Page 75: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/75.jpg)
Intersection with BVHn Don't return intersection immediately if the
other subvolume may have a closer intersection
![Page 76: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/76.jpg)
Intersection Pseudo-codeDoes ray intersect box?intersect_BVH(box, ray, xsect_pt, t)
If no more subboxesIntersect geometry and return nearest xsect_pt & t
Intersect ray with both subboxesNo hits: return xsect_pt = Null;Sort t’sCall subbox of nearest t subbox1intersect_BVH(subbox1, ray, xsect_pt, t)If hit_subbox2?
If xsect_pt == Null || t2near <= t1farintersect_BVH(subbox2, ray, xsect_pt, t)Set nearest xsect_pt and t
Return
![Page 77: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/77.jpg)
Bounding Volume Hierarchy Discussionn Advantages
n easy to constructn easy to traversen binary
n Disadvantagesn may be difficult to choose a good split for a noden poor split may result in minimal spatial pruning
n Hintn Alternate sorting in X, Y & Z
![Page 78: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/78.jpg)
Transformation Hierarchy
n 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 79: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/79.jpg)
What’s the best method?n What kind of scene are you rendering?
n Teapot in a stadium vs. uniform distributionn Impact on surface tessellation on distribution
n Parameter values are critical
![Page 80: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/80.jpg)
Shoot Fewer Raysn Adaptive depth control
n Naïve ray tracer: spawn 2 rays per intersection until max recursion limit
n In practice, few surfaces are transparent or reflective
n Stop shadow ray at first intersection between start and light source
n Just shoot the rays you needn Determine contribution of ray
• Don’t shoot rays w/ contribution near 0%
![Page 81: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/81.jpg)
Shoot Fewer Raysn Adaptive sampling
n Shoot rays coarsely, interpolating their values across pixels
n Where adjacent rays differ greatly in value, sample more finely
n Stop when some maximum resolution is reached
![Page 82: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/82.jpg)
Generalized Raysn Beams, cones, pencilsn Area sampling, rather than point samplingn Geometric computations are tricky
(expensive?)n Problems with reflection/refractions
![Page 83: CS 636 Advanced Rendering Techniquesdavid/Classes/CS636/Lectures/CS636_Pr… · CS 636 Advanced Rendering Techniques Dr. David Breen Online Wednesday 6PM ®8:50PM Presentation 3 4/22/20](https://reader033.vdocuments.site/reader033/viewer/2022050102/5f412f0b9e3b7e517a4ce5ca/html5/thumbnails/83.jpg)
Wrap Upn Discuss next programming assignment
n Add an acceleration technique• Adaptive grid• Bounding volume hierarchy
n Supersample imagen Discuss status/problems/issues with
this week’s programming assignment