Download presentation
Presentation is loading. Please wait.
Published byEsmond Harmon Modified over 9 years ago
1
BSP Tree Supplement Jyun-Ming Chen
2
Fall 20052 Kd-Tree and BSP tree kd-tree is a special kind of bsp tree
3
Fall 20053
4
4 Equation at a Node Defines the hyperplane: ax+by+cz+d=0 Subtree polygons are classified according to the coefficients stored at (internal) nodes
5
Fall 20055 Elements of BSP Construction Choosing the partition plane Auto-partition: choose the partition plane from the input set of polygons It is desirable to have a balanced tree, where each leaf contains roughly the same number of polygons. However, there is some cost in achieving this. [deBerg et al.] choose free splits if possible, else, random selection Partitioning polygons If a polygon happens to span the partition plane, it will be split into two or more pieces. A poor choice of the partition plane can result in many such splits, and a marked increase in the number of polygons.
6
Fall 20056 Elements of BSP Construction (cont) The decision to terminate tree construction can be: when the number of polygons in a leaf node is below a maximum value. until every polygon is placed in an internal node. maximum tree depth.
7
Fall 20057 S3 S2 S3 S1 SIZE=3 Different ordering generates different trees
8
Fall 20058 S3 S2 S2b S2a S2 S3 S3a S3b S1 S2b S3bS2a S3a S1 S2b S3b S2a S3a S2bS2a S3b S3a S3b S3a S3bS3a SIZE=5
9
Fall 20059 Painter ’ s Algorithm Subtleties What do we mean sort in z? That is for a triangle, what is its representative z value? Minimum z Maximum z Polygon ’ s centroid Work cost = sort + draw We still use Painter ’ s Algorithms for blended objects (discussed in the Blending Lesson) An object space visibility algorithm
10
Fall 200510 Painter ’ s Algorithm (cont) Pros: No extra memory Relatively fast Easy to understand and implement Cons: Precision issues (and additional work to handle them) Sort stage Intersecting objects
11
Fall 200511 Painter ’ s Algorithm (BSP Version) S(v) need not be drawn!
12
Fall 200512 Example Scene
13
Fall 200513 A B E C F D G
14
Fall 200514 A E C1C1 F D G C2C2 B2B2 B1B1 D A B 1 C 1 B 2 C 2 EFG + –
15
Fall 200515 A E C1C1 F D G C2C2 B2B2 B1B1 D C1C1 F A B 1 C 2 B 2 EG
16
Fall 200516 A E C1C1 F D G C2C2 B2B2 B1B1 D C1C1 F B1B1 C 2 E G B 2 A Tree completed!
17
Fall 200517 A E C1C1 F D G C2C2 B2B2 B1B1 D C1C1 F B1B1 C 2 E G B 2 A eye Rendering BSP [b-to-f]
18
Fall 200518 A E C1C1 F D G C2C2 B2B2 B1B1 D C1C1 F B1B1 C 2 E G B 2 A eye V hv-hv- hv+hv+
19
Fall 200519 A E C1C1 F D G C2C2 B2B2 B1B1 D C1C1 F B1B1 C 2 E G B 2 A eye V C1 hv-hv- hv+hv+
20
Fall 200520 A E C1C1 F D G C2C2 B2B2 B1B1 D C1C1 F B1B1 C 2 E G B 2 A eye V B1 C1 hv-hv- hv+hv+
21
Fall 200521 A E C1C1 F D G C2C2 B2B2 B1B1 D C1C1 F B1B1 C 2 E G B 2 A eye V B1 C1 A
22
Fall 200522 A E C1C1 F D G C2C2 B2B2 B1B1 D C1C1 F B1B1 C 2 E G B 2 A eye V B1 C1 A D hv-hv- hv+hv+
23
Fall 200523 A E C1C1 F D G C2C2 B2B2 B1B1 D C1C1 F B1B1 C 2 E G B 2 A eye V B1 C1 A D hv-hv- hv+hv+
24
Fall 200524 A E C1C1 F D G C2C2 B2B2 B1B1 D C1C1 F B1B1 C 2 E G B 2 A eye V B1 C1 A D hv-hv- hv+hv+
25
Fall 200525 A E C1C1 F D G C2C2 B2B2 B1B1 D C1C1 F B1B1 C 2 E G B 2 A eye V B1 C1 A D B2
26
Fall 200526 A E C1C1 F D G C2C2 B2B2 B1B1 D C1C1 F B1B1 C 2 E G B 2 A eye V B1 C1 A B2 E D hv-hv- hv+hv+
27
Fall 200527 A E C1C1 F D G C2C2 B2B2 B1B1 D C1C1 F B1B1 C 2 E G B 2 A eye V B1 C1 A B2 E D G
28
Fall 200528 A E C1C1 F D G C2C2 B2B2 B1B1 D C1C1 F B1B1 C 2 E G B 2 A eye V B1 C1 A B2 E D F G hv-hv- hv+hv+
29
Fall 200529 A E C1C1 F D G C2C2 B2B2 B1B1 D C1C1 F B1B1 C 2 E G B 2 A eye V B1 C1 A B2 E D F G hv-hv- hv+hv+ C2
30
Fall 200530 Consider Viewing Direction … [From FAQ] … It is possible to substantially improve the quality of this example by including the viewing direction vector in the computation. You can determine that entire subtrees are behind the viewer by comparing the view vector to the partition plane normal vector. This test can also make a better decision about tree drawing when the eye point lies on the partition plane. Need not consider h v -
31
Fall 200531 Details hvhv v n v n v n
32
Fall 200532 Overdraw Problems Back-to-front: severe overdraw problem Front-to-back: no overdraw problem (with z- buffer). Most practical bsp renderers use this ordering 1000 rectangles Front-to-back: 0.06 sec back-to-front: 0.4 sec
33
Fall 200533 Other Topics History of BSP (H. Fuchs et al. Siggraph80) see bspfaqbspfaq BSP & ray tracing …… & collision detection …… & shadow (SVBSP) …… & motion planning BSP for dynamic scene
34
Fall 200534 BSP & Ray Tracing Speed up ray tracing by: Reaching leaf nodes Determine face through which ray exits Find region-binding faces: collect all parental halfplanes Compute exit points Extending ray into next region … until the ray shoots into infinity
35
Fall 200535 Shadow Volume BSP (2D) (ref)ref For every occluder, we can construct an SVBSP as shown right l a b a b ab lit shadow Same side as ab Not so Same side as l Not so Two types of nodes: i.light-to-endpt ii.occluder Two types of nodes: i.light-to-endpt ii.occluder Chin & Feiner (1989)
36
Fall 200536 SVBSP (cont) Incrementally, insert blockers into SVBSP Split cd into ca ’ and a ’ b Classify a ’ d and find it is in shadow. No need to insert (does not create new shadow) Insert ca ’ into right child of a (shown left) l a b c d a’ a b ab lit shadow c a’ ca’ lit shadow
37
Fall 200537 Query Against SVBSP l a b c d a’ a b ab lit shadow c a’ ca’ lit shadow
38
Fall 200538 BSP in Games (ref)ref To account for character size, use offset planes in BSP Problems when angles between planes are large Character-environment collision detection
39
Fall 200539 Collision Resolution Better to solve a collision by deflecting the motion rather than stopping at the impact point Stepping and climbing
40
Fall 200540 BSP & Collision Detection (Ref)Ref Moving objects (as OBB) [Out of 12 faces, only check with 1, 3, 6, 7]
41
Fall 200541 Dynamic Scenes Moving camera: no problem Moving objects: Fuchs et. al. was to specify a bounding polygon around the area that of the scene that would be changing. Doom: use z-buffer for for dynamic objects (missiles and bullets) Adding objects: no problem Deleting objects: BIG problem (ref)ref
42
Fall 200542 a b c d e f g h i j k l Homework 1.Construct the bsp tree until every line segment is in a leaf node 2.From the given view point, list the ordering (1) back-to-front (2) front-to-back according to the bsp tree 3.Considering viewing direction, list the b-to-f order + –
43
Fall 200543 Ans 1(i,d) 3(k) 2(c) 4(a) 5(g) 7(l) 6(f) b h e j B-2-f: 1+ 3+ 7-, 7, 7+ 3 3- 6-,6,6+ 1 1- 2- 4+,4,4- 2 2+ 5+,5,5-
44
Fall 200544 Ans 1(i,d) 3(k) 2(c) 4(a) 5(g) 7(l) 6(f) b h e j B-2-f: 1+ [3+ 7-, 7, 7+] 3 3- 6-,6,6+ 1 1- 2- 4+,4,4- 2 2+ 5+,5,5-
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.