Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ray Tracing Optimizations

Similar presentations


Presentation on theme: "Ray Tracing Optimizations"— Presentation transcript:

1 Ray Tracing Optimizations
CS 655 Ray Tracing Optimizations

2 Ray Tracing Problems Slow Rays are discrete
Compare every ray vs. every object Rays are discrete Aliasing problems No coherence taken advantage of We would like to optimize our ray tracer Efficiency Generality Quality

3 Optimizations Approaches to optimizing the ray tracer: Data structures
Numerical methods Computational geometry Optics Statistical methods Distributed computing

4 Ray Tracing Optimizations
Criteria for judging acceleration techniques: (from Kirk and Arvo) Simplicity Applicability All rays? All object types? Performance Recources Storage Multiple processors

5 What should we optimize
Say intersections are 80% of the computation. Give an equation which describes the number of intersections. What should we do?

6 Intersection Optimizations
Reduce intersection computation time Reduce the number of intersections Replace individual rays with a more general entity

7 Ray Tracing Acceleration Summary
Acceleration Techniques Faster Intersections Fewer Rays Generalized Rays Faster Ray/Object Intersections Fewer Ray/Object Intersections Object Bounding Volumes Efficient intersectors Bounding Volume Hierarchies Space Subdivision Directional Techniques Adaptive Tree Depth Control Statistical Optimizations Beam Tracing Cone Pencil

8 Ray Tracing Acceleration Summary
Acceleration Techniques Faster Intersections Fewer Rays Generalized Rays Faster Ray/Object Intersections Fewer Ray/Object Intersections Object Bounding Volumes Efficient intersectors Bounding Volume Hierarchies Space Subdivision Directional Techniques Adaptive Tree Depth Control Statistical Optimizations Beam Tracing Cone Pencil

9 Bounding Volumes Idea:
Provide a volume that completely encloses an object, but which has a simpler intersection calculation than the actual object If the ray does not intersect the bounding volume, it will not intersect the object Complex intersections are replaced by simpler ones The number of intersection calculations increases, however Want the bounding volume as near to the object as possible Still a linear time complexity in the number of objects

10 Bounding Volume Example
Bounding Sphere Bounding Sphere hit, object missed Bounding Sphere hit, object hit Bounding Sphere missed, object missed

11 Bounding Volumes Generally, either spheres or axis-aligned bounding volumes are used Simple to intersect against However, these may not provide close fits to the objects being bounded Several different bounding volume types have been used Tradoff – ease of intersection vs. object fit

12 Types of Bounding Volumes
Sphere Axis-aligned Bounding Box Non-axis-aligned Bounding Box Intersection Of Slabs Union of Bounding Boxes Intersection of Bounding Sphere and Bounding Box

13 Ray Tracing Acceleration Summary
Acceleration Techniques Faster Intersections Fewer Rays Generalized Rays Faster Ray/Object Intersections Fewer Ray/Object Intersections Object Bounding Volumes Efficient intersectors Bounding Volume Hierarchies Space Subdivision Directional Techniques Adaptive Tree Depth Control Statistical Optimizations Beam Tracing Cone Pencil

14 Hierarchical Bounding Volumes
Bounding volumes by themselves try to reduce intersection time, but not the number of intersections A bounding volume hierarchy can reduce the number of intersections Place each object in its own bounding volume Group the bounding volumes hierarchically Intersection computations proceed down the hierarchy

15 Hierarchical Bounding Volumes
Around a million triangles Log_2(1M) = about 20

16 Example Bounding Volume Hierarchy
4f 4e 3b 4c 3a 2a 2b 1 1 2a 2b 3a 4a 3b 4d 4c 4b 4e 4f

17 Bounding Volume Hierarchy
Each leaf node is a single object Each interior node consists of a bounding volume and a list of pointers to its children nodes Process: Determine the bounding volume for each object in the scene (usually spheres or orthogonal parallelepipeds) Combine bounding volumes into a tree by selecting some of them and surrounding them with another bounding volume Repeat this process recursively until a bounding volume is generated that surrounds the entire scene

18 Bounding Volume Hierarchy
Once the tree is built, trace rays, intersecting with the hierarchy. If one volume in the hierarchy is missed, you don’t need to intersect the ray with any children of that bounding volume Algorithm: Procedure BVH_Intersect(ray, node) Begin if node is a leaf then Intersect (ray, node_object) else if Intersect_P(ray, node_bounding_volume) then For each child of node BVH_Intersect(ray, child) End

19 Building the BVH Manually Automatically Difficult Simple n-ary tree
Poor, since it doesn’t take the model into consideration Median-cut algorithm Better, but still doesn’t take full advantage of scene properties Heuristic tree search Good, if the heuristic is chosen well

20 Ray Tracing Acceleration Summary
Acceleration Techniques Faster Intersections Fewer Rays Generalized Rays Faster Ray/Object Intersections Fewer Ray/Object Intersections Object Bounding Volumes Efficient intersectors Bounding Volume Hierarchies Space Subdivision Directional Techniques Adaptive Tree Depth Control Statistical Optimizations Beam Tracing Cone Pencil

21 3D Spatial Subdivision Techniques
Start with a volume that bounds the entire environment Successively partition the volume into smaller pieces Objects are grouped based on volumes, rather than vice-versa Several approaches using this idea Uniform spatial subdivision Simple, doesn’t match objects well Non-uniform spatial subdivision More complex, but should give a better fit to the objects

22 Uniform Spatial Subdivision
Voxels are all the same size, organized into a 3D grid Space subdivision is independent of the objects in the scene The “next voxel” calculation can be done very efficiently 3DDDA can be used (three-dimensional digital differential analyzer ) The speedup in the 3DDDA may or may not compensate for the loss of object locality gained in non-uniform methods

23 Uniform Spatial Subdivision
3 1 2 4 Start with a volume enclosing the entire scene Uniformly subdivide it until each subspace contains less than n objects 4 2 5 1 3

24 Non-uniform Spatial Subdivision
Space is discretized into regions of varying size Several approaches Octree BSP Tree Median Split

25 Octrees An octree is created that approximates the scene
The octree is subdivided as necessary based on the scene

26 BSP Trees Another non-uniform spatial subdivision technique is Binary Space Partitioning trees Idea: Split space into two subspaces (not axis aligned) based on the objects in the subspaces Check each subspace. If a subspace has more than n objects, split that subspace into two smaller subspaces Each subspace maintains a list of objects in it

27 BSP Trees 2a 2b 4 2 1 5 3 1 3

28 BSP Trees Divide a ray into two components – one on each side of the partitioning plane Check the nearest sub-ray first If it intersects another plane, subdivide the ray at the plane Intersect the nearest sub-ray against the objects in that space If no intersections, move to the next sub-ray, splitting the ray as necessary, then compute ray/object intersections

29 BSP Example Region 4 2a 2 4 Region 3 Region 2 5 3 1 3 1 Region 5 2b
Ray is split at the 2b plane Region 1 is intersected against Ray is split at plane 1 Region 2 is intersected against Ray is split at plane 2a Region 3 is intersected against Region 4 is intersected against 4 2 Region 3 Region 2 5 1 3 1 3 Region 5 2b ray Region 1

30 Median Split BVH Technique
An alternative method for creating a BVH is the “Median Split” technique Simpler than the Goldsmith and Salmon technique Not as object-centric, however Idea: Split space into two subspaces, based on the dimensions of the space Check each subspace If a subspace has several objects still in it, split it again

31 Median Split 2a 4 2 4a 1 8a 2b 5 6a 8b 5a 7a 1 3 3 8c 4b 6b 7b 5b

32 Median Split Pseudocode
Surround all of the objects in the scene in an axis-aligned bounding box. Determine the largest magnitude extent of the bounding box. Subdivide the bounding box at the middle of the box, in the coordinate direction determined by the extent from step 2. If the level of subdivision is less than m (for m something like 20 or so), and the number of objects in the space is greater than n, (n being some small number like 1 or 5 or 10 or so), subdivide that sub-space by repeating steps 2 through 4 on the sub-space. For each subspace in the final divided space, maintain a list of those objects associated with that sub-space.

33 Median Split With the bounding volume subspaces determined, ray tracing proceeds: Send out a ray Determine which subspace is first hit Compute intersections with all objects associated with that subspace If an intersection exists, report the first intersection If no intersection, proceed to the next subspace hit by the ray and repeat this process

34 Ray Tracing Acceleration Summary
Acceleration Techniques Faster Intersections Fewer Rays Generalized Rays Faster Ray/Object Intersections Fewer Ray/Object Intersections Object Bounding Volumes Efficient intersectors Bounding Volume Hierarchies Space Subdivision Directional Techniques Adaptive Tree Depth Control Statistical Optimizations Beam Tracing Cone Pencil

35 Directional Techniques
Another approach at reducing the number of ray/object intersections is to exploit directional information Move processing to a higher level i.e. rather than on a per ray basis, move computation to a group of rays These techniques typically require large amounts of storage

36 Direction Cube Axis aligned cube centered at (0, 0, 0) with edges of length 2 Cube is placed on the ray origin A ray can now be represented by a face and a (u,v) coordinate on that face Ray

37 Direction Cube The direction cube faces are subdivided into smaller sub-faces Can be either uniform or non uniform Each direction cell defines an infinite skewed pyramid with its apex at the origin and its edges through cell corners

38 Direction Cube Given the subdivided cube we can determine which cell is pierced by each ray Determine the dominant axis of the ray to get the intersection face Determine the (u, v) coordinate Determine which cell this (u, v) point is in Each cell keeps a list of candidate intersection objects based on direction neighborhoods Is this practical for standard rays?

39 The Light Buffer Used to accelerate shadow calculations using the directional idea Assumes point light sources Idea: Each light source is given a uniformly subdivided direction cube. Prior to ray tracing, each object is projected onto each direction cube. Each cell contains a list of all objects that project to that cell. For shadow computations, determine which cell is intersected by the shadow ray, and only intersect objects in that cell’s list

40 The Light Buffer Find where ray intersects light buffer
Intersect against objects in that cell’s list Light Buffer Shadow Ray Point light source Incoming Ray

41 Ray Tracing Acceleration Summary
Acceleration Techniques Faster Intersections Fewer Rays Generalized Rays Faster Ray/Object Intersections Fewer Ray/Object Intersections Object Bounding Volumes Efficient intersectors Bounding Volume Hierarchies Space Subdivision Directional Techniques Adaptive Tree Depth Control Statistical Optimizations Beam Tracing Cone Pencil

42 Beam Tracing Funkhouser et al., “A Beam Tracing method for interactive architectural acoustics” in J. of Acoust. Soc. of Am. 115(2) 2004


Download ppt "Ray Tracing Optimizations"

Similar presentations


Ads by Google