Download presentation
Presentation is loading. Please wait.
Published byWarren Henderson Modified over 9 years ago
1
Computer Graphics 2 Lecture x: Acceleration Techniques for Ray-Tracing Benjamin Mora 1 University of Wales Swansea Dr. Benjamin Mora
2
Introduction 2 Benjamin Mora University of Wales Swansea Why do we need to accelerate Computer Graphics? –Because scenes are more and more complex. –Because we want interactive (~5 fps) or real-time techniques (>30 fps). –Because global illumination algorithms takes hours to render a single image. –Because the naïve algorithms are inefficient (and not just a little). –Because rendering times are proportional to the computational power, which is proportional to the money you invest and CO 2 emissions…
3
Content 3 Benjamin Mora University of Wales Swansea Ray-Tracing Oriented Techniques. –Simple Bounding Boxes (or volumes). –Grids. –Spatial Subdivisions. BSP and K-d Trees. Bounded Volume Hierarchies. Octrees. Hierarchical Grids. –Packed Ray-Tracing. –Multi-Level Ray-Tracing.
4
Ray-Tracing Oriented Techniques. 4 Benjamin Mora University of Wales Swansea
5
Ray-Tracing Oriented Techniques. 5 Benjamin Mora University of Wales Swansea A naïve Ray-Tracer is very inefficient. –Every ray makes an intersection test with all the n primitives in the scene. (Complexity O(n) per ray). –An O(log(n)) complexity per ray can be achieved on average with better techniques. Most acceleration techniques in Ray-Tracing use the concept of bounding boxes that are going to group a spatial subset of primitives.
6
Bounding Boxes 6 Benjamin Mora University of Wales Swansea Example: Naïve algorithm: 12 intersections to be tested to find the closet intersection. Using a Bounding Box for this case: 2 Bounding box intersections at most must be done first+ 6 regular intersections. Because the ray do not intersect the second BB, there is no need to test the inner primitives. (1) (2) Can this optimization also be used in case 2, since the 2 bounding boxes are intersected? Yes, if bounding boxes tests are run in a visibility order!
7
Bounding Boxes 7 Benjamin Mora University of Wales Swansea Bounding boxes are a very basic data structure for Ray-Tracing acceleration. BBs may be: – a sphere (easier to compute). –A cube. –A polyhedra. –… Creating the bounding box (i.e. classifying the primitives) must be done in an intelligent way…
8
Bounding Boxes 8 Benjamin Mora University of Wales Swansea Basic algorithm for every ray: For every bounding box BB: if BB is in front of an already detected intersection and BB is intersected by the ray then test the intersection with all the primitives inside BB. Improvement can be done by testing all the bounding boxes in a Front-to-back order. Another improvement can be to create a hierarchy of BBs. –Similar to spatial subdivisions techniques.
9
Grids 9 Benjamin Mora University of Wales Swansea The 3D space is subdivided with a grid. Every cell contains a list of primitives. –Front-to-back traversal inside a grid is easy. 3D-DDA traversal (See next lectures). –Creating the grid is easier as well (do not need heuristics, unlike BBs). –Average complexity: O(n^ 1/3 ).
10
BSP and Kd-Tree Demo 10 Benjamin Mora University of Wales Swansea
11
Spatial Subdivision Techniques: BSP Trees 11 Benjamin Mora University of Wales Swansea The 3D space is now hierarchically subdivided according a subdividing plane. 1 1 2 3 23 5 4 45
12
Spatial Subdivision Techniques: BSP Trees 12 Benjamin Mora University of Wales Swansea Ray traversal: 1 1 2 2 3 3 5 5
13
Spatial Subdivision Techniques: BSP Trees 13 Benjamin Mora University of Wales Swansea Example:
14
Spatial Subdivision Techniques: BSP Trees 14 Benjamin Mora University of Wales Swansea Example:
15
Spatial Subdivision Techniques: BSP Trees 15 Benjamin Mora University of Wales Swansea Recursive Ray traversal (pseudo-code): int isIntersection (node n, ray r) { int result; if n is a leaf node return isThereAnIntersection(n.primitives, r); else { sortVisibility(n.child1, n.child2, r); if isIntersection(n.child1, r) result=isIntersection(n.child1, r); if result==1 return 1; if isIntersection(n.child2, r) result=isIntersection(n.child2, r); return result; }
16
Spatial Subdivision Techniques: BSP-Trees 16 Benjamin Mora University of Wales Swansea Binary Space Partitioning Trees. Logarithmic rendering complexity on average. Quite hard to find the best heuristic for subdivision. Each node represents a volumetric region delimited by convex polyhedron.
17
Spatial Subdivision Techniques: Kd-Trees 17 Benjamin Mora University of Wales Swansea Axis-aligned BSP tree. 1 1 2 2 3 3 4 4 5 5
18
Spatial Subdivision Techniques: Kd-Trees 18 Benjamin Mora University of Wales Swansea Example:
19
Spatial Subdivision Techniques: Kd-Trees 19 Benjamin Mora University of Wales Swansea BSP Trees that are restricted to axis-aligned space subdivision. –Same properties as BSP trees. Simplify intersection computations a lot. Memory space can be reduced as well. –Only need to store a pointer to the 2 children, the subdivided axis(3 bits) and the location where the subdivision occurs (1 value). Each node represent a volumetric region delimited by a rectangular hexahedron. Very much used in computer graphics.
20
Spatial Subdivision Techniques: Kd-Trees 20 Benjamin Mora University of Wales Swansea Heuristics to compute the tree (According Gordon Stoll, Intel, Course 41, Siggraph 2005). Not very efficients: –Split axis: Largest Extent. –Split Location: Middle of the extent, Centre of gravity of the geometry. –Termination: A given number of primitives, limited depth. Better: –Isolate empty regions of the volume. –Termination :small cell size. –Several time faster.
21
Spatial Subdivision Techniques: Kd-Trees 21 Benjamin Mora University of Wales Swansea Surface Area Heuristic. –Finding the correct splitting position. –Recursive algorithm. Investigate all the vertices in the node and choose the one minimizing the cost: Cost = NodeTraversalCost +TriangleRayIntersectionCost/SA(ParentNode)* (SA(leftNode) leftTriangles+SA(rightNode)*rightTriangles)
22
Spatial Subdivision Techniques: Kd-Trees 22 Benjamin Mora University of Wales Swansea SAH Example
23
Bounding Volume Hierarchies 23 Benjamin Mora University of Wales Swansea
24
Bounding Volume Hierarchies 24 Benjamin Mora University of Wales Swansea A hierarchy of bounding boxes. –MinMax of a set of triangles on x,y, and z coordinates. Triangles in the set are fully included in the bounding box of a specific region. Easier to compute than KD-trees and Octrees. –But are often less efficient than octrees and Kd- Trees at rendering the scene. –Often needs tp carry on traversing, even if an intersection has been detected.
25
Spatial Subdivision Techniques: Octrees 25 Benjamin Mora University of Wales Swansea An octree is a 3D recursive subdivision of space. Every non- leaf node has 8 children. Usually, the subdivision is centered on the middle of the node. May not be as flexible as Kd- Trees. –Small non-empty regions may create “deeper” hierarchy/trees. Useful in volume rendering. –Min-max information stored instead of empty/non-empty information. http://hpcc.engin.umich.edu/CFD/users/charlton/Thesis/html/img148.gif
26
Spatial Subdivision Techniques: Octrees 26 Benjamin Mora University of Wales Swansea
27
Considerations on Tree Traversals 27 Benjamin Mora University of Wales Swansea All spatial subdivisions work in a similar way to accelerate ray-tracing. A recursive top-down traversal of the tree is done. –Starting from the root node. –If node is empty=>Do nothing and Return. –If Leaf Node=>Test for an intersection with the primitives stored inside this node. If an intersection occurs, stop recursion and return the result. –Otherwise, find out the children of the current node that are intersected by the ray, sort them in a visibility order, and call again the function with these nodes.
28
Special case: Octrees 28 Benjamin Mora University of Wales Swansea 1 2 3 5 4 6 9 A C B A AB C 7 8
29
Special case: Octrees 29 Benjamin Mora University of Wales Swansea A ray can intersect between two and four of the eight possible children. Octree node visibility order (Painter’s algorithm, 2D example!) 2 and 3 can be swapped! Viewpoint 12 34 24 13
30
Spatial Subdivision Techniques: Hierarchical Grids 30 Benjamin Mora University of Wales Swansea Similar to octrees, but the node is now grid- subdivided. Subdivision can be: –Regular. –Adaptive. Not so much used!
31
Packet Ray-Tracing 31 Benjamin Mora University of Wales Swansea Also called coherent ray-tracing. Reasons: –Taking advantage of new processors: SIMD Architectures: Single instructions applied 4 times. –Often 3x speed-up Cell processor: 8 cores with SIMD capabilities. Intersection test performed on 4 rays instead of one. –Taking advantage of spatial coherence. Neighbor rays will similarly traverse the acceleration structure. A lot of traversal steps can be avoided. From 2x2 to 16x16 ray packets.
32
Multi-Level Ray-Tracing 32 Benjamin Mora University of Wales Swansea Multi-level ray tracing algorithm Alexander Reshetov, Alexei Soupikov and Jim Hurley. Siggraph 2005 (ACM Transactions on Graphics), pp 1176-1185. Go a step further to improve the tree traversal. Tries to find the entry point in the tree for an as large as possible packet of rays. See paper for more information!
33
Multi-Level Ray-Tracing 33 Benjamin Mora University of Wales Swansea
34
Multi-Level Ray-Tracing 34 Benjamin Mora University of Wales Swansea
35
Multi-Level Ray-Tracing 35 Benjamin Mora University of Wales Swansea
36
Future of Ray-Tracing 36 Benjamin Mora University of Wales Swansea Games? –Some people do believe so… –Hard to maintain acceleration structures on dynamic scenes. High quality rendering. –Certainly. –Movies. –Global illumination algorithms. –Etc…
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.