anti-aliased and accelerated ray tracing
TRANSCRIPT
![Page 1: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/1.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell
Anti-aliased and acceleratedray tracing
![Page 2: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/2.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 2
ReadingRequired:
Watt, sections 12.5.3 – 12.5.4, 14.7Further reading:
A. Glassner. An Introduction to Ray Tracing. AcademicPress, 1989. [In the lab.]
![Page 3: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/3.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 3
Aliasing in renderingOne of the most common rendering artifacts is the“jaggies”. Consider rendering a white polygonagainst a black background:
We would instead like to get a smoother transition:
![Page 4: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/4.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 4
Anti-aliasingQ: How do we avoid aliasing artifacts?
1. Sampling:2. Pre-filtering:3. Combination:
Example - polygon:
![Page 5: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/5.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 5
Polygon anti-aliasing
![Page 6: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/6.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 6
Antialiasing in a ray tracerWe would like to compute the average intensity in the neighborhood ofeach pixel.
When casting one ray per pixel, we are likely to have aliasing artifacts.To improve matters, we can cast more than one ray per pixel andaverage the result.A.k.a., super-sampling and averaging down.
![Page 7: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/7.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 7
Speeding it upVanilla ray tracing is really slow!Consider: m x m pixels, k x k supersampling, and nprimitives, average ray path length of d, with 2 rays castrecursively per intersection.Complexity =For m=1,000,000, k = 5, n = 100,000, d=8…veryexpensive!!In practice, some acceleration technique is almost alwaysused.We’ve already looked at reducing d with adaptive raytermination.Now we look at reducing the effect of the k and n terms.
![Page 8: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/8.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 8
Antialiasing by adaptive samplingCasting many rays per pixel can be unnecessarily costly.For example, if there are no rapid changes in intensity atthe pixel, maybe only a few samples are needed.Solution: adaptive sampling.
Q: When do we decide to cast more rays in a particulararea?
![Page 9: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/9.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 9
Let’s say you were intersecting a ray with a polyhedron:
Straightforward methodintersect the ray with each trianglereturn the intersection with the smallest t-value.
Q: How might you speed this up?
Faster ray-polyhedron intersection
![Page 10: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/10.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 10
Ray Tracing Acceleration Techniques
1N
Faster Intersection
Fewer Rays
Generalized Rays
Approaches
Tighter boundsFaster intersector
Uniform gridsSpatial hierarchies k-d, oct-tree, bsp hierarchical gridsHierarchical bounding volumes (HBV)
Early ray terminationAdaptive sampling
Beam tracingCone tracingPencil tracing
![Page 11: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/11.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 11
Uniform spatial subdivisionAnother approach is uniform spatial subdivision.
Idea:Partition space into cells (voxels)Associate each primitive with the cells it overlapsTrace ray through voxel array using fast incremental arithmetic tostep from cell to cell
![Page 12: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/12.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 12
Uniform Grids
Preprocess sceneFind bounding box
![Page 13: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/13.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 13
Uniform Grids
Preprocess sceneFind bounding box
Determine resolutionv x y z on n n n n= !
3max( , , )x y z on n n d n=
![Page 14: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/14.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 14
Uniform Grids
Preprocess sceneFind bounding boxDetermine resolution
Place object in cell, ifobject overlaps cell
3max( , , )x y z on n n d n=
![Page 15: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/15.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 15
Uniform Grids
Preprocess sceneFind bounding boxDetermine resolution
Place object in cell, ifobject overlaps cellCheck that objectintersects cell
3max( , , )x y z on n n d n=
![Page 16: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/16.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 16
Uniform Grids
Preprocess sceneTraverse grid3D line – 3D-DDA6-connected line
![Page 17: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/17.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 17
Caveat: Overlap
Optimize for objects that overlap multiple cells
Traverse until tmin(cell) > tmax(ray)Problem: Redundant intersection tests:Solution: Mailboxes
Assign each ray an increasing numberPrimitive intersection cache (mailbox)
Store last ray number tested in mailboxOnly intersect if ray number is greater
![Page 18: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/18.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 18
Non-uniform spatial subdivisionStill another approach is non-uniform spatial subdivision.
Other variants include k-d trees and BSP trees.
Various combinations of these ray intersections techniques are alsopossible. See Glassner and pointers at bottom of project web page formore.
![Page 19: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/19.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 19
Non-uniform spatial subdivisionBest approach - k-d trees or perhaps BSP trees
More adaptive to actual scene structureBSP vs. k-d tradeoff between speed from simplicity and better adaptability
0
1
2
4
7 8
5 6
3
![Page 20: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/20.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 20
Spatial Hierarchies
A
A
Letters correspond to planes (A)Point Location by recursive search
![Page 21: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/21.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 21
Spatial Hierarchies
B
A
B
A
Letters correspond to planes (A, B)Point Location by recursive search
![Page 22: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/22.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 22
Spatial Hierarchies
CB
D
C
D
A
B
A
Letters correspond to planes (A, B, C, D)Point Location by recursive search
![Page 23: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/23.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 23
Variations
oct-treekd-tree bsp-tree
![Page 24: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/24.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 24
Ray Traversal Algorithms
Recursive inorder traversal[Kaplan, Arvo, Jansen]
mint
maxt *t
max*t t<
*t
min max*t t t< <
*t
min*t t<
Intersect(L,tmin,tmax) Intersect(R,tmin,tmax)Intersect(L,tmin,t*)Intersect(R,t*,tmax)
![Page 25: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/25.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 25
Build Hierarchy Top-Down
Choose splitting plane• Midpoint• Median cut• Surface area heuristic
?
![Page 26: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/26.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 26
Surface Area and RaysNumber of rays in a given direction that hit anobject is proportional to its projected area
The total number of rays hitting an object isCrofton’s Theorem:
For a convex body
For example: sphere 4
SA =
4 A!
24S r!=
A
2A A r!= =
![Page 27: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/27.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 27
Surface Area and Rays
The probability of a ray hitting a convex shapethat is completely inside a convex cell equals
Pr[ ] o
o c
c
Sr S r S
S! ! =
oSc
S
![Page 28: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/28.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 28
Surface Area Heuristic
t a a i b b iC t p N t p N t= + +
80i tt t=a b
it
tt
Intersection time
Traversal time
![Page 29: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/29.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 29
Surface Area Heuristic
aa
Sp
S= b
b
Sp
S=
2n splits
a b
![Page 30: Anti-aliased and accelerated ray tracing](https://reader030.vdocuments.us/reader030/viewer/2022012605/619a868c0368a04f4a3094f5/html5/thumbnails/30.jpg)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 30
Hierarchical bounding volumesWe can generalize the idea of bounding volume acceleration withhierarchical bounding volumes.
Key: build balanced trees with tight bounding volumes.
Many different kinds of bounding volumes.Note that bounding volumes can overlap.