Acceleration Data Structures for Ray Tracing Most slides are taken - - PowerPoint PPT Presentation

acceleration data structures for ray tracing
SMART_READER_LITE
LIVE PREVIEW

Acceleration Data Structures for Ray Tracing Most slides are taken - - PowerPoint PPT Presentation

Acceleration Data Structures for Ray Tracing Most slides are taken from Fredo Durand Extra rays needed for these effects: Distribution Ray Tracing Soft shadows Anti-aliasing (getting rid of jaggies) g (g g j gg ) Glossy


slide-1
SLIDE 1

Acceleration Data Structures for Ray Tracing

Most slides are taken from Fredo Durand

slide-2
SLIDE 2

Extra rays needed for these effects:

  • Distribution Ray Tracing

– Soft shadows – Anti-aliasing (getting rid of jaggies) g (g g j gg ) – Glossy reflection Motion blur – Motion blur – Depth of field (focus)

slide-3
SLIDE 3

Shadows

  • one shadow ray per

i i i intersection per point light source

no shadow rays

  • ne shadow ray
slide-4
SLIDE 4

Soft Shadows

  • multiple shadow rays

l li h to sample area light source

  • ne shadow ray

lots of shadow rays

slide-5
SLIDE 5

Antialiasing – Supersampling

  • multiple

jaggies w/ antialiasing

rays per pixel

point light area light g

slide-6
SLIDE 6

Reflection

  • one reflection ray per intersection

perfect mirror θ θ p θ θ

slide-7
SLIDE 7

Glossy Reflection

  • multiple reflection

rays

Justin Legakis Justin Legakis

polished surface θ θ p θ θ

slide-8
SLIDE 8

Motion Blur

  • Sample objects

ll temporally

Rob Cook

slide-9
SLIDE 9

Algorithm Analysis

  • Ray casting

cost ≤ height * width *

  • Lots of primitives
  • Recursive

num primitives * intersection cost * num shadow rays *

  • Distributed Ray

Tracing Effects

num shadow rays * supersampling * num glossy rays *

Tracing Effects – Soft shadows Anti aliasing

g y y num temporal samples * max recursion depth *

– Anti-aliasing – Glossy reflection

. . .

– Motion blur – Depth of field can we reduce this? p

slide-10
SLIDE 10

The Ray Tree

T3

E

R

2

R R N2 T1 T3

Eye

R

1 3

L2 L3 N1 N3 L1 L1

3 1

L L T1 R

1

Ni surface normal R reflected ray

T3 R L3 L2 R Eye

Ri reflected ray Li shadow ray T t itt d ( f t d)

3 2

Ti transmitted (refracted) ray

slide-11
SLIDE 11

Questions?

slide-12
SLIDE 12

Accelerating Ray Tracing

  • Four main groups of acceleration techniques:

– Reducing the average cost of intersecting a ray with a scene:

  • Faster intersection calculations
  • Fewer intersection calculations

– Reducing the total number of rays that are traced

  • Adaptive recursion depth control

p p

– Discrete Ray Tracing

  • proximity clouds

proximity clouds

– Using generalized rays P ll li ti i li d h d – Parallelization, specialized hardware

slide-13
SLIDE 13

Acceleration of Ray Casting

  • Goal: Reduce the

b f number of ray/primitive intersections

slide-14
SLIDE 14

Bounding Volumes

  • Idea: associate with each object a simple bounding

l If i th b di l it l

  • volume. If a ray misses the bounding volume, it also

misses the object contained therein.

  • Common bounding volumes:

– spheres – bounding boxes – bounding slabs

  • Effective for additional applications:

– Clipping acceleration pp g – Collision detection

  • Note: bounding volumes offer no asymptotic

Note: bounding volumes offer no asymptotic improvement!

slide-15
SLIDE 15

Conservative Bounding Region

  • First check for an

i i i h intersection with a conservative bounding region

  • Early reject
  • Early reject
slide-16
SLIDE 16

Conservative Bounding Regions

bounding sphere

  • tight → avoid

p

false positives

  • fast to intersect
  • fast to intersect

non-aligned bounding box axis-aligned b di b bounding box arbitrary convex region (bounding half-spaces)

slide-17
SLIDE 17

Bounding Volumes

slide-18
SLIDE 18

Bounding Boxes can overlap

slide-19
SLIDE 19

Intersection with Axis-Aligned Box

From Lecture 3,

  • For all 3 axes,

Ray Casting II

For all 3 axes, calculate the intersection distances t1 and t2

  • tnear = max (t1x, t1y, t1z)

tfar = min (t2x, t2y, t2z)

y=Y2 tfar t2x

  • If tnear> tfar,

box is missed

y Y2 t t2y

  • If tfar< tmin,

box is behind

y=Y1 tnear t1x

  • If box survived tests,

report intersection at tnear

y Y1 x=X1 x=X2 t1y

slide-20
SLIDE 20

Bounding Volume Hierarchy

  • Introduced by James Clark (SGI, Netscape) in

f ffi i i f lli 1976 for efficient view-frustum culling.

Procedure IntersectBVH(ray, node) ( y, ) begin if IsLeaf(node) then Intersect(ray, node.object) else if IntersectBV(ray,node.boundingVolume) then foreach child of node do IntersectBVH(ray, child) endfor endif end

slide-21
SLIDE 21

Bounding Volume Hierarchy

  • Find bounding box of objects
  • Split objects into two groups
  • Recurse
  • Recurse
slide-22
SLIDE 22

Bounding Volume Hierarchy

  • Find bounding box of objects
  • Split objects into two groups
  • Recurse
  • Recurse
slide-23
SLIDE 23

Bounding Volume Hierarchy

  • Find bounding box of objects
  • Split objects into two groups
  • Recurse
  • Recurse
slide-24
SLIDE 24

Bounding Volume Hierarchy

  • Find bounding box of objects
  • Split objects into two groups
  • Recurse
  • Recurse
slide-25
SLIDE 25

Bounding Volume Hierarchy

  • Find bounding box of objects
  • Split objects into two groups
  • Recurse
  • Recurse
slide-26
SLIDE 26

Where to split objects?

  • At midpoint OR
  • Sort, and put half of the objects on each side OR
  • Use modeling hierarchy
slide-27
SLIDE 27

Intersection with BVH

  • Check subvolume with closer intersection first
slide-28
SLIDE 28

Intersection with BVH

  • Don't return intersection immediately if the

h b l h l i i

  • ther subvolume may have a closer intersection
slide-29
SLIDE 29

Questions?

slide-30
SLIDE 30

Regular Grid

slide-31
SLIDE 31

Create grid

  • Define grid resolution, not

il b

Cell (i, j)

necessarily cubes

gridy id gridx

slide-32
SLIDE 32

Insert primitives into grid

  • Primitives that overlap multiple cells?
  • Insert bbx into multiple cells (use pointers)
slide-33
SLIDE 33

For each cell along a ray

  • Does the cell contain an intersection?
  • Yes: return closest intersection
  • No: continue
slide-34
SLIDE 34

Preventing repeated computation

  • Perform the computation once, "mark" the object
  • Don't re-intersect marked objects
slide-35
SLIDE 35

Don't return distant intersections

  • If intersection t is not within the cell range,

ti (th b thi l ) continue (there may be something closer)

slide-36
SLIDE 36

Where do we start?

  • Intersect ray

ith

Cell (i j)

with scene bounding box

Cell (i, j)

  • Ray origin

may be inside the scene bounding box

tnext h tmin tnext_v

next_h

t tnext_v t

t h

tmin tnext_h

slide-37
SLIDE 37

Is there a pattern to cell crossings?

  • Yes, the

h i t l horizontal and vertical i crossings have regular spacing

dtv = gridy / diry

spacing

dt = grid / dir gridy dth = gridx / dirx id (dirx, diry) gridx

slide-38
SLIDE 38

What's the next cell?

if tnext_v < tnext_h i + i Cell (i+1, j) Cell (i, j) i += signx tmin = tnext_v d tnext_v += dtv else tnext h j += signy tmin = tnext_h t i tnext_v tnext_h dt tnext_h += dth tmin dtv dth (dirx, diry) if (dir > 0) sign = 1 else sign = -1 if (dirx > 0) signx 1 else signx

  • 1

if (diry > 0) signy = 1 else signy = -1

slide-39
SLIDE 39

What's the next cell?

  • 3DDDA – Three

Di i l Di it l Dimensional Digital Difference Analyzer

  • We saw this

again earlier, for line rasterization

slide-40
SLIDE 40

Regular Grid Discussion

  • Advantages?

– easy to construct – easy to traverse y

Di d t ?

  • Disadvantages?

– may be only sparsely filled – geometry may still be clumped

slide-41
SLIDE 41

Questions?

slide-42
SLIDE 42

Adaptive Grids

  • Subdivide until each cell contains no more than

l t i d th d i h d n elements, or maximum depth d is reached

N d G id O /(Q d ) Nested Grids Octree/(Quadtree)

slide-43
SLIDE 43

Primitives in an Adaptive Grid

  • Can live at intermediate levels, or

b h d t l t l l f id be pushed to lowest level of grid

O /(Q d ) Octree/(Quadtree)

slide-44
SLIDE 44

Top down traversal

Split ray into sub-segments and traverse each segment i l recursively.

slide-45
SLIDE 45

Bottom Up traversal

Step from cell to cell. Intersect current cell and add an il i t th t ll epsilon into the next cell. Then search for the cell in the tree. tree. A naïve search starts from the root. Otherwise, try an intelligent guess…

slide-46
SLIDE 46

Kd-trees vs. Quad-tree

slide-47
SLIDE 47

Kd-trees vs. BSP-tree

slide-48
SLIDE 48

Adaptive Spatial Subdivision

  • Disadvantages of uniform subdivision:

– requires a lot of space – traversal of empty regions of space can be slow p y g p – not suitable for “teapot in a stadium” scenes

  • Solution: use a hierarchical adaptive spatial
  • Solution: use a hierarchical adaptive spatial

subdivision data structure

– octrees – BSP-trees

  • Given a ray, perform a depth-first traversal of the

tree Again can stop once an intersection has

  • tree. Again, can stop once an intersection has

been found.

slide-49
SLIDE 49

Bounding Volume Hierarchy Discussion

  • Advantages

– easy to construct – easy to traverse – binary

  • Disadvantages

– may be difficult to choose a good split for a node – poor split may result in minimal spatial pruning

slide-50
SLIDE 50

Uniform vs. Adaptive Subdivision

slide-51
SLIDE 51

Macro-regions

slide-52
SLIDE 52

Proximity Clouds

slide-53
SLIDE 53
slide-54
SLIDE 54

Parallel/Distributed RT

  • Two main approaches:

– Each processor is in charge of tracing a subset of the

  • rays. Requires a shared memory architecture,

replication of the scene database, or transmission of

  • bjects between processors on demand.

– Each processor is in charge of a subset of the scene (either in terms of space, or in terms of objects). ( p , j ) Requires processors to transmit rays among themselves.

slide-55
SLIDE 55

Directional Techniques

  • Light buffer: accelerates shadow rays.

– Discretize the space of directions around each light source using the direction cube g g – In each cell of the cube store a sorted list of

  • bjects visible from the light source through that
  • bjects visible from the light source through that

cell – Given a shadow ray locate the appropriate cell of Given a shadow ray locate the appropriate cell of the direction cube and test the ray with the

  • bjects on its list
  • bjects on its list
slide-56
SLIDE 56

Directional Techniques

  • Ray classification (Arvo and Kirk 87):

R i 3D h 5 d f f d (  ) – Rays in 3D have 5 degrees of freedom: (x,y,z,) – Rays coherence: rays belonging to the same small 5D i hb h d lik l t i t t th t f bj t neighborhood are likely to intersect the same set of objects. – Partition the 5D space of rays into a collection of 5D hypercubes each containing a list of objects hypercubes, each containing a list of objects. – Given a ray, find the smallest containing 5D hypercube, and test the ray against the objects on the list test the ray against the objects on the list. – For efficiency, the hypercubes are arranged in a hierarchy: a 5D analog of the 3D octree. This data structure is constructed 5 a a og o e 3

  • c ee.

s da a s uc u e s co s uc ed in a lazy fashion.