1
Hidden Surface�Determination
Reading
Optional
2
The Quest for 3D
3
Introduction
4
Object Space Algorithms
5
Image Space Algorithms
6
n m2
d m2
Object Order vs. Image Order
7
Sort First vs. Sort Last
8
Important Algorithms
9
Ray Casting
10
Ray Casting, cont.
r(t) = c + t (Pij - c)
Q: Given the set {ti} what is the first intersection point?
11
Aside: Definitions
12
Ray Casting Analysis
13
Z-buffer
14
void draw_mode_setup( void ) {
…
GlEnable( GL_DEPTH_TEST );
…
}
Z-buffer Implementation
15
for each pixel pi
{
Z-buffer[ pi ] = FAR
Fb[ pi ] = BACKGROUND_COLOR
}
for each polygon P
{
for each pixel pi in the projection of P
{
Compute depth z and shade s of P at pi
if z < Z-buffer[ pi ]
{
Z-buffer[ pi ] = z
Fb[ pi ] = s
}
}
}
Visibility tricks for Z-buffers
Z-buffering is the algorithm of choice for hardware rendering
What is the complexity of the Z-buffer algorithm?
What can we do to decrease the constants?
16
Z-buffer Tricks
17
(R1,G1,B1,z1)
(R2,G2,B2,z2)
(R3,G3,B3,z3)
Z value interpolation
18
Scan line
Depth Preserving�Conversion to Parallel Projection
19
Computing Z
20
Z-buffer Analysis
21
Binary Space Partitioning
22
A
B
C
D
Building a BSP Tree (in 2D)
23
Alternate BSP Tree
24
1
2
3
4
5
1
2
3
4
5
back
back
back
front
BSP Tree Construction
25
BSPtree makeBSP( L: list of polygons )
{
if L is empty
{
return the empty tree
}
Choose a polygon P from L to serve as root
Split all polygons in L according to P
return new TreeNode(
P,
makeBSP( polygons on negative side of P ),
makeBSP( polygons on positive side of P ))
}
BSP Tree Display
26
showBSP( v: Viewer, T: BSPtree )
{
if T is empty then return
P := root of T
if viewer is in front of P
{
showBSP( back subtree of T )
draw P
showBSP( front subtree of T )
} else {
showBSP( front subtree of T )
draw P
showBSP( back subtree of T )
}
}
BSP Tree Applications
27
BSP Analysis
28
Back Face Culling
29
Summary
30