Download presentation
Presentation is loading. Please wait.
1
Anti-aliased and accelerated ray tracing
2
Reading Required: Further reading:
Watt, sections – , 14.7 Further reading: A. Glassner. An Introduction to Ray Tracing. Academic Press, [In the lab.] University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
3
Aliasing in rendering Sketch the triangle that would create the given image -- lower right corner coverage. Called the jaggies. Point to frame 1, 4, 7, 10, 13 One of the most common rendering artifacts is the “jaggies”. Consider rendering a white polygon against a black background: We would instead like to get a smoother transition: University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
4
Anti-aliasing Q: How do we avoid aliasing artifacts? Sampling:
1. Increase sampling rate -- not practical for fixed resolution display. 2. Smooth out high frequences analytically. Requires an analytic function. 3. Supersample and average down. Q: How do we avoid aliasing artifacts? Sampling: Pre-filtering: Combination: Example - polygon: University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
5
Polygon anti-aliasing
Show anti-aliased image with ray sample. A: Motion blur Draw a dot streaking across the screen, first as jumps then as smear. University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
6
Antialiasing in a ray tracer
Put a box around the “support of a pixel”. Show ray-traced output We would like to compute the average intensity in the neighborhood of each 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 and average the result. A.k.a., super-sampling and averaging down. University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
7
Speeding it up Vanilla ray tracing is really slow!
Put a box around the “support of a pixel”. Show ray-traced output Vanilla ray tracing is really slow! Consider: m x m pixels, k x k supersampling, and n primitives, average ray path length of d, with 2 rays cast recursively per intersection. Complexity = For m=1,000,000, k = 5, n = 100,000, d=8…very expensive!! In practice, some acceleration technique is almost always used. We’ve already looked at reducing d with adaptive ray termination. Now we look at reducing the effect of the k and n terms. University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
8
Antialiasing by adaptive sampling
|I1 - I2| > thresh I1/I2 or I2/I1 > 1 + thresh better since it’s based on relative values, which is the way the eye perceives. Show how ray sample doesn’t take 16X longer to trace. Casting many rays per pixel can be unnecessarily costly. For example, if there are no rapid changes in intensity at the pixel, maybe only a few samples are needed. Solution: adaptive sampling. Q: When do we decide to cast more rays in a particular area? University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
9
Faster ray-polyhedron intersection
Let’s say you were intersecting a ray with a polyhedron: Straightforward method intersect the ray with each triangle return the intersection with the smallest t-value. Q: How might you speed this up? University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
10
Ray Tracing Acceleration Techniques
1 N Faster Intersection Fewer Rays Generalized Approaches Tighter bounds Faster intersector Uniform grids Spatial hierarchies k-d, oct-tree, bsp hierarchical grids Hierarchical bounding volumes (HBV) Early ray termination Adaptive sampling Beam tracing Cone tracing Pencil tracing Readings Arvo and Kirk Arvo, Metahierarchies Havran and “Best Efficiency Scheme” Beam tracing techniques fail for two reasons: Intersection calculations are too complicated; imagine cone-algebraic surface Beams don’t remain closed under reflection and refraction off curved surfaces Bounds First test bounds, then do detailed intersection calculation Trade-off on how tight the bounds are; the tighter the bound, the higher the Probability of a real intersection given an intersection with the bound, but the higher the cost of rejection. University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
11
Uniform spatial subdivision
Another approach is uniform spatial subdivision. Idea: Partition space into cells (voxels) Associate each primitive with the cells it overlaps Trace ray through voxel array using fast incremental arithmetic to step from cell to cell University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
12
Uniform Grids Preprocess scene Find bounding box
Two reasons for using a grid. Cull out objects not near the ray. Only consider those objects in the voxels along the ray’s path Early termination. Stop when you find the point of closest intersection. University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
13
Uniform Grids Preprocess scene Find bounding box Determine resolution
Setting the resolution is tricky. If the resolution is too high, then you step through too many voxels. If the resolution is too low, then you perform too many intersections. Add Tim’s study of voxel density. Roughly set so that the average time spent walking voxels is equal to the average time spent test for intersection. D=3 is typical. Woo describes an algorithm for non-uniformly allocating voxels in each direction. D is the voxel density, and was introduced by Cleary and Wyvill? University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
14
Uniform Grids Preprocess scene Find bounding box Determine resolution
Place object in cell, if object overlaps cell University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
15
Uniform Grids Preprocess scene Find bounding box Determine resolution
Place object in cell, if object overlaps cell Check that object intersects cell Could remove interior voxels as well. University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
16
Uniform Grids Preprocess scene Traverse grid 3D line – 3D-DDA
6-connected line University of Texas at Austin CS384G - Computer Graphics Fall 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 number Primitive intersection cache (mailbox) Store last ray number tested in mailbox Only intersect if ray number is greater Mailboxes first proposed by Amanaidas and Woo Each ray is assigned a unique number. Latter rays have higher numbers than earlier rays. Store the ray number with each primitive. Don’t test rays if their ray number is less than or equal to the primitive’s ray number. University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
18
Non-uniform spatial subdivision
Still another approach is non-uniform spatial subdivision. Other variants include k-d trees and BSP trees. Various combinations of these ray intersections techniques are also possible. See Glassner and pointers at bottom of project web page for more. University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
19
Non-uniform spatial subdivision
Best approach - k-d trees or perhaps BSP trees More adaptive to actual scene structure BSP vs. k-d tradeoff between speed from simplicity and better adaptability 1 2 3 4 5 6 7 8 University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
20
Spatial Hierarchies Letters correspond to planes (A)
As questions? Kay-Kajiya Properties of hierarchical bounding volumes … A Letters correspond to planes (A) Point Location by recursive search University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
21
Spatial Hierarchies Letters correspond to planes (A, B)
As questions? Kay-Kajiya Properties of hierarchical bounding volumes … Letters correspond to planes (A, B) Point Location by recursive search University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
22
Spatial Hierarchies Letters correspond to planes (A, B, C, D)
As questions? Kay-Kajiya Properties of hierarchical bounding volumes … Letters correspond to planes (A, B, C, D) Point Location by recursive search University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
23
Variations kd-tree oct-tree bsp-tree
Kd-tree where you set the position of the splitting plane. Oct-tree where you set the position of the center point. kd-tree oct-tree bsp-tree University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
24
Ray Traversal Algorithms
Recursive inorder traversal [Kaplan, Arvo, Jansen] Intersect(L,tmin,tmax) Intersect(L,tmin,t*) Intersect(R,t*,tmax) Intersect(R,tmin,tmax) University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
25
Build Hierarchy Top-Down
? What exactly is the surface-area heuristic Choose splitting plane Midpoint Median cut Surface area heuristic University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
26
Surface Area and Rays Number of rays in a given direction that hit an
object is proportional to its projected area The total number of rays hitting an object is Crofton’s Theorem: For a convex body For example: sphere University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
27
Surface Area and Rays The probability of a ray hitting a convex shape
that is completely inside a convex cell equals Question after class. How is this used? Need to show in detail how this information Is used to find the optimal hierarchy. University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
28
Surface Area Heuristic
Intersection time Traversal time What exactly is the surface-area heuristic a b University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
29
Surface Area Heuristic
b 2n splits What exactly is the surface-area heuristic University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
30
Hierarchical bounding volumes
We can generalize the idea of bounding volume acceleration with hierarchical bounding volumes. Key: build balanced trees with tight bounding volumes. Many different kinds of bounding volumes. Note that bounding volumes can overlap. University of Texas at Austin CS384G - Computer Graphics Fall Don Fussell
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.