CS 655 - PowerPoint PPT Presentation

1 / 52
About This Presentation
Title:

CS 655

Description:

This may (probably does) produce a sub-optimal tree ... Check the nearest sub-ray first. If it intersects another plane, subdivide the ray at the plane ... – PowerPoint PPT presentation

Number of Views:55
Avg rating:3.0/5.0
Slides: 53
Provided by: parrisk
Category:
Tags: suboptimal

less

Transcript and Presenter's Notes

Title: CS 655


1
CS 655
  • Ray Tracing Optimizations

2
Ray Tracing Problems
  • Slow
  • 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
Intersection Optimizations
  • Reduce intersection computation time
  • Reduce the number of intersections
  • Replace individual rays with a more general entity

6
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

7
Bounding Volume Example
Bounding Sphere
Bounding Sphere hit, object missed
Bounding Sphere hit, object hit
Bounding Sphere missed, object missed
8
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

9
Types of Bounding Volumes
10
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

11
Example Bounding Volume Hierarchy
4b
4d
4a
4f
4e
3b
4c
3a
2a
2b
1
1
2a
2b
3a
4d
3b
4a
4c
4b
4f
4e
12
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

13
Bounding Volume Hierarchy
  • Once the tree is built, trace rays, intersecting
    with the hierarchy.
  • If one volume in the hierarchy is missed, you
    dont 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

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

15
Goldsmith and Salmon approach
  • Observations
  • Must be able to handle many objects (hundreds of
    thousands)
  • Checking all possible nodes will be too slow
  • Limit the search to a small portion of the nodes
  • This may (probably does) produce a sub-optimal
    tree
  • This is okay, as long as it still works
    better/faster than other techniques
  • Heuristic
  • Search only the subtree of a node that would give
    the smallest increase in surface area to the node
    if the new node were to be inserted as a child of
    it.

16
Goldsmith and Salmon Algorithm
  • Create root node
  • For each object x do
  • Insert node x as a child of the root node
  • Compute the increase in surface area
  • For the original root node, it is the sum of the
    surface areas of all children
  • For other nodes, it is the surface area of the
    enclosing bounding volume
  • Insert node x as a child of each node i that is a
    child of the root.
  • If node i is currently a leaf node
  • Create a new node j.
  • Insert nodes i and x as children nodes of node j
  • Compute increase in surface area caused by the
    new node j
  • Select the location which produces the smallest
    increase in surface area
  • If that location is the root node, insert the new
    node as a child of the root node
  • Otherwise, repeate steps 2a-g with the candidate
    node as the root node

17
Goldsmith and Salmon example
Scene before creating the hierarchy Each object
is surrounded by its bounding volume The black
rectangle is the entire scene
18
1st Iteration
Current Tree
Possibilities
19
2nd Iteration
Current Tree
Possibilities
20
3rd Iteration
Current Tree
Possibilities
21
4th Iteration
Current Tree
Possibilities
22
5th Iteration
Current Tree
Possibilities
4
5
5
5
5
1
3
23
5th Iteration Recursive
Current Tree
5
Possibilities
24
Goldsmith and Salmon Technique
  • The order in which the objects are inserted has a
    huge influence on how good the tree is
  • They experimented with
  • User supplied order
  • Shuffled
  • Sorted by line

Number of intersection Calculations per Ray
User supplied or shuffled generally best
25
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, doesnt match objects well
  • Non-uniform spatial subdivision
  • More complex, but should give a better fit to the
    objects

26
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
  • The speedup in the 3DDDA may or may not
    compensate for the loss of object locality gained
    in non-uniform methods

27
From Stephen Ward
Biplane 300 x 300 No 3DDDA No Anti-Aliasing 115
minutes
Biplane 300 x 300 3DDDA Anti-Aliasing 50 minutes
28
Skull 300 x 300 No 3DDDA No Anti-Aliasing 95
minutes
Skull 300 x 300 3DDDA Anti-Aliasing 8 minutes
29
Spheres 300 x 300 No 3DDDA No Anti-Aliasing 1.5
minutes
Spheres 300 x 300 3DDDA Anti-Aliasing 1.5
minutes
30
Uniform Spatial Subdivision
  • Start with a volume enclosing the entire scene
  • Uniformly subdivide it until each subspace
    contains less than n objects

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

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

33
Octree Spatial Subdivision
  • Each voxel has a list of objects whose surfaces
    penetrate the volume
  • When a ray penetrates a voxel, the list of
    objects for that voxel is used for possible
    intersections
  • Objects are tested for intersection with the 6
    voxel faces
  • If no intersection occurs, a point on the object
    is tested for being inside the voxel
  • Start with a box which contains all objects
  • Recursively subdivide the box until each voxel
    contains fewer than n objects in its list

34
Octree Subdivision
  • (shown in the 2-D case here)

35
Octree Algorithm
  • Locate the voxel which contains the ray origin
  • Perform intersection calculations
  • Determine the next voxel
  • compute ray/box intersection with the current
    voxel
  • move slightly beyond that point
  • Intersections near edges and vertices can cause
    problems

36
Octree Algorithm
  • Procedure Octree-intersect(ray)
  • Begin
  • Q ray.origin
  • Repeat
  • Locate the voxel containing Q
  • For each object associated with that voxel do
  • Intersect (ray, object)
  • If no intersection has been found then
  • Q the point in the next voxel pierced by the
    ray
  • Until an intersection is found, or Q is outside
    the bounding box of the environment

37
(No Transcript)
38
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

39
BSP Trees
40
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

41
BSP Example
Region 4
2a
  • 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

Region 3
Region 2
1
Region 5
2b
Region 1
ray
42
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

43
Median Split
44
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.

45
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

46
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

47
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
48
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

49
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?

50
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 cells list

51
The Light Buffer
  • Find where ray intersects light buffer
  • Intersect against objects in that cells list

Light Buffer
Shadow Ray
Point light source
Incoming Ray
52
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
  • Tracing
  • Pencil
  • Tracing
Write a Comment
User Comments (0)
About PowerShow.com