CS-184: Computer Graphics Lecture #7: BSP and AABB Trees Brandon - - PowerPoint PPT Presentation

cs 184 computer graphics
SMART_READER_LITE
LIVE PREVIEW

CS-184: Computer Graphics Lecture #7: BSP and AABB Trees Brandon - - PowerPoint PPT Presentation

CS-184: Computer Graphics Lecture #7: BSP and AABB Trees Brandon Wang and Prof. James OBrien University of California, Berkeley V2013-S-07-1.0 1 Announcements Assignment 2: Soon... 2 2 Sunday, February 24, 13 BSP-Trees Binary Space


slide-1
SLIDE 1

CS-184: Computer Graphics

Lecture #7: BSP and AABB Trees

Brandon Wang and Prof. James O’Brien University of California, Berkeley

V2013-S-07-1.0

Announcements

Assignment 2: Soon...

2

1 2 Sunday, February 24, 13

slide-2
SLIDE 2

3

BSP-Trees

  • Binary Space Partition Trees
  • Split space along planes
  • Allows fast queries of some spatial relations
  • Simple construction algorithm
  • Select a plane as sub-tree root
  • Everything on one side to one child
  • Everything on the other side to other child
  • Use random polygon for splitting plane

4

a,b,c,d,e,f,g

BSP-Trees

a b c d e g f

3 4 Sunday, February 24, 13

slide-3
SLIDE 3

5

a b,c1,d c2,e,f,g

a b c1 d e g f c2

BSP-Trees

6

a b c2,e,f,g c1 d

a b c1 d e g f c2

BSP-Trees

5 6 Sunday, February 24, 13

slide-4
SLIDE 4

7

a b c2 c1 d e1 ,f e2 ,g

a b c1 d g f c2 e1 e2

BSP-Trees

8

a b c2 c1 d e1 e2 ,g f

a b c1 d g f c2 e1 e2

BSP-Trees

7 8 Sunday, February 24, 13

slide-5
SLIDE 5

9

a b c2 c1 d e1 e2 f g

a b c1 d g f c2 e1 e2

BSP-Trees

+

  • +
  • +
  • +

+ + + + +

10

BSP-Trees

  • Visibility Traversal
  • Variation of in-order-traversal
  • Child one
  • Sub-tree root
  • Child two
  • Select “child one” based on location of viewpoint
  • Child one on same side of sub-tree root as viewpoint

9 10 Sunday, February 24, 13

slide-6
SLIDE 6

11

a b c2 c1 d e1 e2 f g

a b c1 d g f c2 e1 e2

BSP-Trees

c1:b:d:a:f:e1:c2:g:e2

12

g:e2:c2:f:e1:a:c1:b:d

a b c2 c1 d e1 e2 f g

a b c1 d g f c2 e1 e2

BSP-Trees

11 12 Sunday, February 24, 13

slide-7
SLIDE 7

Your Ray Tracer

RayTrace(image)

For ray in camera image[pixel] = Trace(ray)

Trace(ray)

t_hit = infinity For object in scene t_hit = min(object.intersect(ray), t_hit) shade at t_hit possible calls to Trace(new_ray)

13

Your Ray Tracer

RayTrace(image)

For ray in camera image[pixel] = Trace(ray)

Trace(ray)

t_hit = infinity For object in scene t_hit = min(object.intersect(ray), t_hit) shade at t_hit possible calls to Trace(new_ray)

14

13 14 Sunday, February 24, 13

slide-8
SLIDE 8

Your Ray Tracer

RayTrace(image)

For ray in camera image[pixel] = Trace(ray)

Trace(ray)

t_hit = infinity For object in scene t_hit = min(object.intersect(ray), t_hit) shade at t_hit possible calls to Trace(new_ray)

15

Bounding Shapes

  • Bounding shape completely encloses associated object
  • Rays cannot hit object w/o intersecting bounding shape
  • Two objects cannot collide if shapes don’t overlap
  • Simplicity -vs- tightness

16

15 16 Sunday, February 24, 13

slide-9
SLIDE 9

Axis-Aligned Bounding Boxes

  • Axis-aligned bounding box defined by min and max x,y,z

17

Min x,y,z Max x,y,z

Axis-Aligned Bounding Boxes

18

Transform box Not axis-aligned Min/max of new points Linear cost to compute

17 18 Sunday, February 24, 13

slide-10
SLIDE 10

19

Axis-Aligned Bounding Boxes

Min/max of transformed BB points Constant time Adds slop Cumulative slop if multiple transforms occur sequentially

Why would we do this?

Tightness

20

19 20 Sunday, February 24, 13

slide-11
SLIDE 11

Box Intersection

21

Bounding Box of Bounding Boxes

22

21 22 Sunday, February 24, 13

slide-12
SLIDE 12

Overlapping Triangles

23

Overlapping Triangles

24

23 24 Sunday, February 24, 13

slide-13
SLIDE 13

AABB Trees

25 26

AABB Trees

Robot L.Foot RFoot Head L.Arm R.Arm L.Leg R.Leg Torso Mouth L.Eye R.Eye Head Shape Leg Shape Leg Shape

Group node Geometry node Transformation stored at all nodes

One of many variations

25 26 Sunday, February 24, 13

slide-14
SLIDE 14

Head Shape B.Box Geometry Scale 2x Transformation XF B.Box

27

AABB Trees

Robot L.Foot RFoot Head L.Arm R.Arm L.Leg R . L e g Torso Mouth L.Eye R.Eye Head Shape Leg Shape Leg Shape

One of many variations

Geometry node

XF B.Box Children Rot -25 Transformation Head Union B.Box XF B.Box

28

AABB Trees

Robot L.Foot RFoot Head L.Arm R.Arm L.Leg R . L e g Torso Mouth L.Eye R.Eye Head Shape Leg Shape Leg Shape

One of many variations

Group node

27 28 Sunday, February 24, 13

slide-15
SLIDE 15

29

AABB Trees

One of many variations

Robot L.Foot RFoot Head L.Arm R.Arm L.Leg R.Leg Torso Mouth L.Eye R.Eye Head Shape Leg Shape Leg Shape

Local Bounding Boxes

Robot L.Foot RFoot Head L.Arm R.Arm L.Leg R.Leg Torso Mouth L.Eye R.Eye Head Shape Leg Shape Leg Shape

30

AABB Trees

One of many variations

Transformed Bounding Boxes

29 30 Sunday, February 24, 13

slide-16
SLIDE 16

31

AABB Trees

One of many variations

Robot L.Foot RFoot Head L.Arm R.Arm L.Leg R.Leg Torso Mouth L.Eye R.Eye Head Shape Leg Shape Leg Shape Robot L.Foot RFoot Head L.Arm R.Arm L.Leg R.Leg Torso Mouth L.Eye R.Eye Head Shape Leg Shape Leg Shape

32

AABB Trees

One of many variations

31 32 Sunday, February 24, 13

slide-17
SLIDE 17

33

AABB Trees

One of many variations

Robot L.Foot RFoot Head L.Arm R.Arm L.Leg R.Leg Torso Mouth L.Eye R.Eye Head Shape Leg Shape Leg Shape Robot L.Foot RFoot Head L.Arm R.Arm L.Leg R.Leg Torso Mouth L.Eye R.Eye Head Shape Leg Shape Leg Shape

34

AABB Trees

One of many variations

33 34 Sunday, February 24, 13

slide-18
SLIDE 18

35

Ray Test Against Bound Tree

  • RayHitSubTree(&ray,node)
  • If RayHitsBB(ray,node.xfBB)
  • ixfRay = Inverse(node.xf)*ray
  • If RayHitsBB(ixfRay,node.BB)
  • If node is group
  • Foreach child in node.children
  • RayHitSubTree(ixfRay,child)
  • else // node not group
  • RayHitGeometry(ixfRay,node.geom)
  • ray.collisionInfo.update(ixfRay)

Building the tree

  • Sort (or QuickSelect)

and split on one axis

  • Repeat for the other

axis

  • x,y,z

36

35 36 Sunday, February 24, 13

slide-19
SLIDE 19

Other Schemes

  • Uniform Grid/Octrees
  • Spatial Hierarchies
  • Etc

37

Voxels/Octree

  • http://www.youtube.com/

watch?v=sciLNxmMTXM

38

37 38 Sunday, February 24, 13