Docsity

Acceleration Data Structures for Ray Tracing in MIT EECS 6.837 Course, Slides of Computer Graphics and Animation

Toggle sidebar
bg1
1
MIT EECS 6.837, Durand and Cutler
Acceleration Data Structures
for Ray Tracing
MIT EECS 6.837, Durand and Cutler
Today
•Review & Schedule
• Motivation – Distribution Ray Tracing
• Bounding Boxes
• Spatial Acceleration Data Structures
• Flattening the transformation hierarchy
MIT EECS 6.837, Durand and Cutler
Cool results from Assignment 2
koi seantek
MIT EECS 6.837, Durand and Cutler
Last Week:
• Ray Tracing
– Shadows
– Reflection
– Refraction
• Local Illumination
– Bidirectional Reflectance
Distribution Function
(BRDF)
– Phong Model
θi
θr
φiφr
MIT EECS 6.837, Durand and Cutler
Schedule
• Wednesday October 1st:
Assignment 3 (Ray Tracing & Phong Materials) due
• Sunday October 5th, 5-7 PM, Room TBA:
Review Session for Quiz 1
• Tuesday October 7th:
Quiz 1: In class
• Wednesday October 15th:
Assignment 4 (Grid Acceleration) due
MIT EECS 6.837, Durand and Cutler
Questions?
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Acceleration Data Structures for Ray Tracing in MIT EECS 6.837 Course and more Slides Computer Graphics and Animation in PDF only on Docsity!

MIT EECS 6.837, Durand and Cutler

Acceleration Data Structures

for Ray Tracing

MIT EECS 6.837, Durand and Cutler

Today

• Review & Schedule

• Motivation – Distribution Ray Tracing

• Bounding Boxes

• Spatial Acceleration Data Structures

• Flattening the transformation hierarchy

MIT EECS 6.837, Durand and Cutler

Cool results from Assignment 2

koi seantek

MIT EECS 6.837, Durand and Cutler

Last Week:

• Ray Tracing

– Shadows

– Reflection

– Refraction

• Local Illumination

– Bidirectional Reflectance

Distribution Function

(BRDF)

– Phong Model

θ r θ i

φ i (^) φ r

Schedule

• Wednesday October 1st:

Assignment 3 (Ray Tracing & Phong Materials) due

• Sunday October 5th, 5- 7PM, Room TBA:

Review Session for Quiz 1

• Tuesday October 7 th:

Quiz 1: In class

• Wednesday October 15th:

Assignment 4 (Grid Acceleration) due

Questions?

MIT EECS 6.837, Durand and Cutler

Today

• Review & Schedule

• Motivation – Distribution Ray Tracing

• Bounding Boxes

• Spatial Acceleration Data Structures

• Flattening the transformation hierarchy

MIT EECS 6.837, Durand and Cutler

Extra rays needed for these effects:

• Distribution Ray Tracing

– Soft shadows

– Anti- aliasing (getting rid of jaggies)

– Glossy reflection

– Motion blur

– Depth of field (focus)

MIT EECS 6.837, Durand and Cutler

Shadows

• one shadow ray per

intersection per point

light source

no shadow rays

one shadow ray MIT EECS 6.837, Durand and Cutler

Soft Shadows

• multiple shadow rays

to sample area light

source

one shadow ray

lots of shadow rays

Antialiasing – Supersampling

• multiple

rays per

pixel

point light

area light

jaggies w/ antialiasing

• one reflection ray per intersection

perfect mirror

Reflection

θ θ

MIT EECS 6.837, Durand and Cutler

Acceleration of Ray Casting

• Goal: Reduce the

number of

ray/primitive

intersections

MIT EECS 6.837, Durand and Cutler

Conservative Bounding Region

• First check for an

intersection with a

conservative

bounding region

• Early reject

MIT EECS 6.837, Durand and Cutler

Conservative Bounding Regions

axis-aligned bounding box

non-aligned bounding box

bounding sphere

arbitrary convex region (bounding half-spaces)

• tight → avoid

false positives

• fast to intersect

MIT EECS 6.837, Durand and Cutler

Intersection with Axis-Aligned Box

From Lecture 3,

Ray Casting II

  • For all 3 axes, calculate the intersection distances t 1 and t 2
  • tnear = max (t1x, t1y, t1z) tfar = min (t2x, t2y, t2z)
  • If tnear > tfar, box is missed
  • If tfar< tmin, box is behind
  • If box survived tests, report intersection at tnear

y=Y

y=Y

x=X1 x=X

t (^) nea r

t (^) far

t (^) 1x

t (^) 1y

t (^) 2x

t (^) 2y

Bounding Box of a Triangle

(x (^) min, y (^) min, z (^) min)

(x (^) max, y (^) max, z (^) max) (x 0 , y 0 , z 0 )

(x 1 , y 1 , z 1 )

(x 2 , y 2 , z 2 )

= (min(x 0 ,x 1 ,x 2 ), min(y 0 ,y 1 ,y 2 ), min(z 0 ,z 1 ,z 2 ))

= (max(x 0 ,x 1 ,x 2 ), max(y 0 ,y 1 ,y 2 ), max(z 0 ,z 1 ,z 2 ))

Bounding Box of a Sphere

r

(x (^) min , y (^) min , z (^) min)

(x (^) max, y (^) max, z (^) max)

(x, y, z)

= (x-r, y-r, z-r)

= (x+r, y+r, z+r)

MIT EECS 6.837, Durand and Cutler

Bounding Box of a Plane

(x (^) min, y (^) min , z (^) min)

(x (^) max, y (^) max, z (^) max)

n = (a, b, c)

ax + by + cz = d

  • unless n is exactly perpendicular to an axis MIT EECS 6.837, Durand and Cutler

Bounding Box of a Group

(x (^) min_b , y (^) min_b , z (^) min_b)

(x (^) min , y^ min , z^ min)

(x (^) max, y (^) max, z (^) max)

= (min(x (^) min_a ,x (^) min_b), min(y (^) min_a ,y (^) min_b), min(z (^) min_a ,z (^) min_b))

= (max(x (^) max_a ,x (^) max_b), max(y (^) max_a ,y (^) max_b), max(z (^) max_a ,z (^) max_b))

(x (^) min_a , y (^) min_a , z (^) min_a)

(x (^) max_b , y (^) max_b , z (^) max_b)

(x (^) max_a , y (^) max_a , z (^) max_a)

MIT EECS 6.837, Durand and Cutler

Bounding Box of a Transform

(x' (^) min, y' (^) min, z' (^) min)

(x' (^) max , y'max , z'max)

= (min(x 0 ,x 1 ,x 2 ,x 3 ,x 4 ,x 5 ,x 6 ,x 7 ), min(y 0 ,y 1 ,y 2 ,y 3 ,y 4 ,x 5 ,x 6 ,x 7 ), min(z 0 ,z 1 ,z 2 ,z 3 ,z 4 ,x 5 ,x 6 ,x 7 ))

M

(x (^) min, y (^) min , z (^) min)

(x 0 ,y 0 ,z 0 ) = M (x (^) min,y (^) min,z (^) min)

= (max(x 0 ,x 1 ,x 2 ,x 3 ,x 4 ,x 5 ,x 6 ,x 7 ), max(y 0 ,y 1 ,y 2 ,y 3 ,y 4 ,x 5 ,x 6 ,x 7 ), max(z 0 ,z 1 ,z 2 ,z 3 ,z 4 ,x 5 ,x 6 ,x 7 ))

(x 1 ,y 1 ,z 1 ) = M (x (^) max ,y (^) min,zmin)

(x 2 ,y 2 ,z 2 ) = M (x (^) min,y (^) max ,zmin)

(x 3 ,y 3 ,z 3 ) = M (x (^) max ,y (^) max ,z (^) min)

(x (^) max , ymax , zmax)

MIT EECS 6.837, Durand and Cutler

Special Case: Transformed Triangle

M

Can we do better?

Special Case: Transformed Triangle

(x (^) max , ymax , zmax) = (max(x' 0 ,x' 1 ,x' 2 ), max(y' 0 ,y' 1 ,y' 2 ), max(z' 0 ,z' 1 ,z' 2 )) M

(x (^) min, y (^) min, z (^) min) = (min(x' 0 ,x' 1 ,x' 2 ), min(y' 0 ,y' 1 ,y' 2 ), min(z' 0 ,z' 1 ,z' 2 ))

(x' 0 ,y' 0 ,z' 0 ) = M (x 0 ,y 0 ,z 0 ) (x' 1 ,y' 1 ,z' 1 ) = M (x 1 ,y 1 ,z 1 ) (x'^2 ,y'^2 ,z'^2 ) = M (x 2 ,y 2 ,z 2 ) (x 2 , y 2 , z 2 )

(x 1 , y 1 , z 1 )

(x 0 , y 0 , z 0 )

Questions?

MIT EECS 6.837, Durand and Cutler

Don't return distant intersections

• If intersection

t is not within

the cell range,

continue

(there may be

something

closer)

MIT EECS 6.837, Durand and Cutler

Where do we start?

• Intersect ray

with scene

bounding box

• Ray origin

may be inside

the scene

bounding box

tmin

tnext_v

tnext_h

tmin

tnext_v tnext_h

Cell (i, j)

MIT EECS 6.837, Durand and Cutler

Is there a pattern to cell crossings?

• Yes, the

horizontal

and vertical

crossings

have regular

spacing

dtv = grid (^) y / dir (^) y

dth = grid (^) x / dir (^) x grid^ y

grid (^) x

( dir (^) x , dir (^) y )

MIT EECS 6.837, Durand and Cutler

What's the next cell?

dth dtv

Cell (i, j)

if tnext_v < tnext_h i += signx tmin = tnext_v tnext_v += dtv else j += signy tmin = tnext_h tnext_h += dth

tmin

tnext_v

tnext_h

Cell (i+ 1 , j)

( dir (^) x, dir (^) y )

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

What's the next cell?

• 3DDDA – Three

Dimensional Digital

Difference Analyzer

• We'll see this

again later, for

line rasterization

Pseudo-code

create grid insert primitives into grid for each ray r find initial cell c(i,j), t (^) min, t (^) next_v & t (^) next_h compute dt (^) v, dt (^) h, sign (^) x and sign (^) y while c != NULL for each primitive p in c intersect r with p if intersection in range found return c = find next cell

MIT EECS 6.837, Durand and Cutler

Regular Grid Discussion

• Advantages?

– easy to construct

– easy to traverse

• Disadvantages?

– may be only sparsely filled

– geometry may still be clumped

MIT EECS 6.837, Durand and Cutler

Questions?

MIT EECS 6.837, Durand and Cutler

Today

• Review & Schedule

• Motivation – Distribution Ray Tracing

• Bounding Boxes

• Spatial Acceleration Data Structures

– Regular Grid

– Adaptive Grids

– Hierarchical Bounding Volumes

• Flattening the transformation hierarchy

MIT EECS 6.837, Durand and Cutler

Adaptive Grids

Nested Grids Octree/(Quadtree)

• Subdivide until each cell contains no more than

n elements, or maximum depth d is reached

Primitives in an Adaptive Grid

• Can live at intermediate levels, or

be pushed to lowest level of grid

Octree/(Quadtree)

Adaptive Grid Discussion

• Advantages?

– grid complexity matches geometric density

• Disadvantages?

– more expensive to traverse (especially octree)

MIT EECS 6.837, Durand and Cutler

Intersection with BVH

• Check subvolume with closer intersection first

MIT EECS 6.837, Durand and Cutler

Intersection with BVH

• Don't return intersection immediately if the

other subvolume may have a closer intersection

MIT EECS 6.837, Durand and Cutler

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

MIT EECS 6.837, Durand and Cutler

Today

• Review & Schedule

• Motivation – Distribution Ray Tracing

• Bounding Boxes

• Spatial Acceleration Data Structures

• Flattening the transformation hierarchy

Transformation Hierarchy

group

group

transform

transform

transform

transform

A C

D E

• Group & Transformation

hierarchy may not be a

good spatial hierarchy

transform B

group

transform A B

transform C D

transform C E

Flatten

Questions?

Assignment 4 (due Oct 15th^ )

• Bounding boxes for primitives

• Regular grid acceleration data structure

• Flatten the transformation hierarchy

• Collect statistics

– Average # of rays per pixel

– Average # of ray/primitive intersections per pixel

• Extra Credit: Distribution Ray Tracing

(and anything else from past weeks)

Next Time:

Curves & Surfaces