Title: BSP Tree Supplement
1BSP Tree Supplement
2Kd-Tree and BSP tree
- kd-tree is a special kind of bsp tree
3(No Transcript)
4Equation at a Node
- Defines the hyperplane axbyczd0
- Subtree polygons are classified according to the
coefficients stored at (internal) nodes
5Elements 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.
6Elements 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.
7Different ordering generates different trees
S3
S3
S2
S2
S3
S1
SIZE3
S2
8S3
S2b S3b
S2a S3a
S2
SIZE5
S1
9Painters Algorithm Subtleties
- What do we mean sort in z? That is for a
triangle, what is its representative z value? - Minimum z
- Maximum z
- Polygons centroid
- Work cost sort draw
- We still use Painters Algorithms for blended
objects (discussed in the Blending Lesson) - An object space visibility algorithm
10Painters 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
11Painters Algorithm (BSP Version)
S(v) need not be drawn!
12Example Scene
13A
C
B
D
E
F
G
14A
D
B1
C1
D
A B1 C1
B2 C2 EFG
B2
C2
E
F
G
15A
D
B1
C1
D
C1
F
B2
C2
E
F
A B1
C2
B2 EG
G
16A
D
B1
C1
D
C1
F
B2
C2
E
F
B1
C2
E
G
G
B2
A
Tree completed!
17Rendering BSP b-to-f
A
D
B1
C1
D
C1
F
C2
E
F
B2
B1
C2
E
G
G
eye
B2
A
18V
A
D
B1
hv
C1
D
C1
F
C2
hv-
E
F
B2
B1
C2
E
G
G
eye
B2
A
19A
D
B1
C1
hv-
V
D
C1
F
C2
hv
E
F
B2
B1
C2
E
G
G
eye
B2
A
C1
20A
D
B1
C1
hv-
D
C1
F
C2
hv
E
F
V
B2
B1
C2
E
G
G
eye
B2
A
C1
B1
21A
D
B1
C1
D
C1
F
C2
E
F
B2
B1
C2
E
G
V
G
eye
B2
A
A
C1
B1
22V
A
D
B1
hv
C1
D
C1
F
C2
hv-
E
F
B2
B1
C2
E
G
G
eye
B2
A
A
C1
B1
D
23A
D
B1
C1
D
V
C1
F
C2
hv-
hv
E
F
B2
B1
C2
E
G
G
eye
B2
A
A
C1
B1
D
24A
D
B1
C1
D
C1
F
C2
hv-
hv
V
E
F
B2
B1
C2
E
G
G
eye
B2
A
A
C1
B1
D
25A
D
B1
C1
D
C1
F
C2
E
F
B2
B1
C2
E
G
V
G
eye
B2
A
A
C1
B1
D
B2
26A
D
B1
C1
D
C1
F
C2
hv-
hv
E
F
V
B2
B1
C2
E
G
G
eye
B2
A
A
C1
B1
D
B2
E
27A
D
B1
C1
D
C1
F
C2
E
F
B2
B1
C2
E
G
V
G
eye
B2
A
A
C1
B1
D
B2
G
E
28A
D
B1
C1
D
V
C1
F
C2
hv-
hv
E
F
B2
B1
C2
E
G
G
eye
B2
A
A
C1
B1
D
B2
G
E
F
29A
D
B1
C1
D
C1
F
C2
hv-
hv
V
E
F
B2
B1
C2
E
G
G
eye
B2
A
A
C1
B1
D
C2
B2
G
E
F
30Consider 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 hv-
31Details
v
hv
v
n
n
v
n
32Overdraw Problems
- Back-to-front severe overdraw problem
- Front-to-back no overdraw problem (with
z-buffer). Most practical bsp renderers use this
ordering
Front-to-back 0.06 sec
back-to-front 0.4 sec
1000 rectangles
33Other Topics
- History of BSP (H. Fuchs et al. Siggraph80) see
bspfaq - BSP ray tracing
- collision detection
- shadow (SVBSP)
- motion planning
- BSP for dynamic scene
34BSP 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
35Shadow Volume BSP (2D) (ref)
Chin Feiner (1989)
- For every occluder, we can construct an SVBSP as
shown right
- Two types of nodes
- light-to-endpt
- occluder
36SVBSP (cont)
- Incrementally, insert blockers into SVBSP
- Split cd into ca and ab
- Classify ad and find it is in shadow. No need to
insert (does not create new shadow) - Insert ca into right child of a (shown left)
37Query Against SVBSP
38BSP in Games (ref)
Character-environment collision detection
- To account for character size, use offset planes
in BSP - Problems when angles between planes are large
39Collision Resolution
- Better to solve a collision by deflecting the
motion rather than stopping at the impact point - Stepping and climbing
40BSP Collision Detection (Ref)
Moving objects (as OBB)
Out of 12 faces, only check with 1, 3, 6, 7
41Dynamic 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)
42Homework
- Construct the bsp tree until every line segment
is in a leaf node - From the given view point, list the ordering (1)
back-to-front (2) front-to-back according to the
bsp tree - Considering viewing direction, list the b-to-f
order
43Ans
1(i,d)
B-2-f 1 3 7-, 7, 7
3 3-
6-,6,6 1 1- 2-
4,4,4- 2
2 5,5,5-
2(c)
3(k)
4(a)
5(g)
7(l)
6(f)
b
h
e
j
44Ans
1(i,d)
B-2-f 1 3 7-, 7, 7
3 3-
6-,6,6 1 1- 2-
4,4,4- 2
2 5,5,5-
2(c)
3(k)
4(a)
5(g)
7(l)
6(f)
b
h
e
j