cs 184 computer graphics
play

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


  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 1 Announcements Assignment 2: Soon... 2 2 Sunday, February 24, 13

  2. 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 3 3 BSP-Trees a,b,c,d,e,f,g e a d f b g c 4 4 Sunday, February 24, 13

  3. BSP-Trees a e a b,c 1 ,d c 2 ,e,f,g d f c 2 b g c 1 5 5 BSP-Trees a e a b c 2 ,e,f,g d f c 1 d c 2 b g c 1 6 6 Sunday, February 24, 13

  4. BSP-Trees a e 1 e 2 a b c 2 d f c 1 d e 1 ,f e 2 ,g c 2 b g c 1 7 7 BSP-Trees a e 1 e 2 a b c 2 d f e 1 c 1 d e 2 ,g c 2 b f g c 1 8 8 Sunday, February 24, 13

  5. BSP-Trees a + - e 1 e 2 a + + b c 2 d f + - + - e 1 c 1 d e 2 + c 2 b + + + f g g c 1 9 9 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 10 10 Sunday, February 24, 13

  6. BSP-Trees a e 1 e 2 a b c 2 d f e 1 c 1 d e 2 c 2 b f g g c 1 c 1 :b:d:a:f:e 1 :c 2 :g:e 2 11 11 BSP-Trees a e 1 e 2 a b c 2 d f e 1 c 1 d e 2 c 2 b f g g c 1 g:e 2 :c 2 :f:e 1 :a:c 1 :b:d 12 12 Sunday, February 24, 13

  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 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 14 Sunday, February 24, 13

  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 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 16 Sunday, February 24, 13

  9. Axis-Aligned Bounding Boxes Max x,y,z Min x,y,z • Axis-aligned bounding box defined by min and max x,y,z 17 17 Axis-Aligned Bounding Boxes Transform box Min/max of new points Not axis-aligned Linear cost to compute 18 18 Sunday, February 24, 13

  10. 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? 19 19 Tightness 20 20 Sunday, February 24, 13

  11. Box Intersection 21 21 Bounding Box of Bounding Boxes 22 22 Sunday, February 24, 13

  12. Overlapping Triangles 23 23 Overlapping Triangles 24 24 Sunday, February 24, 13

  13. AABB Trees 25 25 AABB Trees One of many variations Robot L.Arm Torso R.Arm Head L.Leg R.Leg Head Mouth L.Eye R.Eye Shape Leg Leg Group node L.Foot RFoot Shape Shape Geometry node Transformation stored at all nodes 26 26 Sunday, February 24, 13

  14. AABB Trees One of many variations Robot Torso L.Arm R.Arm Head L.Leg R . L e g Head Mouth L.Eye R.Eye Shape Geometry node Leg Leg L.Foot RFoot Shape Shape Head Shape Scale 2x Geometry B.Box Transformation XF B.Box 27 27 AABB Trees One of many variations Robot Torso L.Arm R.Arm Head L.Leg R . L e g Head Mouth L.Eye R.Eye Shape Group node Leg Leg L.Foot RFoot Shape Shape Head Rot -25 Children Union B.Box Transformation XF B.Box XF B.Box 28 28 Sunday, February 24, 13

  15. AABB Trees One of many variations Robot L.Arm Torso Head R.Arm L.Leg R.Leg Head Mouth L.Eye R.Eye Shape Leg Leg L.Foot RFoot Shape Shape Local Bounding Boxes 29 29 AABB Trees One of many variations Robot L.Arm Torso Head R.Arm L.Leg R.Leg Head Mouth L.Eye R.Eye Shape Leg Leg L.Foot RFoot Shape Shape Transformed Bounding Boxes 30 30 Sunday, February 24, 13

  16. AABB Trees One of many variations Robot L.Arm Torso Head R.Arm L.Leg R.Leg Head Mouth L.Eye R.Eye Shape Leg Leg L.Foot RFoot Shape Shape 31 31 AABB Trees One of many variations Robot L.Arm Torso Head R.Arm L.Leg R.Leg Head Mouth L.Eye R.Eye Shape Leg Leg L.Foot RFoot Shape Shape 32 32 Sunday, February 24, 13

  17. AABB Trees One of many variations Robot L.Arm Torso Head R.Arm L.Leg R.Leg Head Mouth L.Eye R.Eye Shape Leg Leg L.Foot RFoot Shape Shape 33 33 AABB Trees One of many variations Robot L.Arm Torso Head R.Arm L.Leg R.Leg Head Mouth L.Eye R.Eye Shape Leg Leg L.Foot RFoot Shape Shape 34 34 Sunday, February 24, 13

  18. 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) 35 35 Building the tree • Sort (or QuickSelect) and split on one axis • Repeat for the other axis • x,y,z 36 36 Sunday, February 24, 13

  19. Other Schemes • Uniform Grid/Octrees • Spatial Hierarchies • Etc 37 37 Voxels/Octree • http://www.youtube.com/ watch?v=sciLNxmMTXM 38 38 Sunday, February 24, 13

Recommend


More recommend