Professional Documents
Culture Documents
08 Hidden Surface Elimination
08 Hidden Surface Elimination
2016-11-21
Visual Realism
- Achieved by correct rendering of :
- View (perspective)
- Field of view (Clip outside the window)
- Omit hidden parts
- Surface details like texture
- Light effects on surfaces like continuous shading, shadows,
and caustics.
- Volumetric effects like transparency and translucency
through participating media like water, steam, smoke, …
- Dynamic effects like movement, elasticity, …
Computer Graphics @ ZJU Hongxin Zhang, 2016
OpenGL functions
- glEnable / glDisable (GL_CULL_FACE);
- glCullFace(mode)
v
Z
u high
n
Y H
low
W
X u
Orthographic Perspective
projector
ViewWindow
Algorithm:
1. Find angle between the eye-vector & normal to face.
2. If between 0 to 90°, discard the face.
Nf
Dp
What happens when the projectors are along Z axis, i.e., (0,0,1)
is the view direction.
Let Nf = (nx,ny,nz), the dot product now equals nz. If this is +ve,
then this is a back-face!
Computer Graphics @ ZJU Hongxin Zhang, 2016
Back-Face Culling
13
Computer Graphics @ ZJU Hongxin Zhang, 2016
Back-Face Culling
14
Computer Graphics @ ZJU Hongxin Zhang, 2016
Back-face Culling
Area Sorting
Clipping
F-Buffer Z-Buffer
view
x
point
Scan Line
P3
Q3
(xp,yp,d)
P2 Q2
Q1
P1
Orthographic Perspective
P3 Q3
Ax + By + Cz + D = 0 P2 Q2
P1 Q1
DDA
x++, y++
z+??
Question: how?
Computer Graphics @ ZJU Hongxin Zhang, 2016
P3 Q3 P3
Q3
(xp,yp,d) P (xp,yp,d)
P
P2 Q2 P2
Q2
(0,0,0)
Q1
P1 Q1 P1
Ax + By + Cz + D = 0
(x, y, z)! (x, y, d) (x, y, z) ! (xp, yp, d)
perspective project
(x,y,z)! (xp,yp,z) Perspective
Transformation
Orthographic
project
(xp,yp,d)
Perspective Transformation...
• We need to apply a perspective transformation to the
view volume and transform it into a rectangular
parallel-piped one
n=-1 n=+1
- image space:
- do scan conversion from deepest surfaces
32
Computer Graphics @ ZJU Hongxin Zhang, 2016
BSP Tree
B C
A B
B
B C
rasterize(C) rasterize(B)
rasterize(A) rasterize(A)
rasterize(B) rasterize(C)
• Cons:
Computationally intense preprocess stage restricts algorithm to static scenes
Worst-case time to construct tree: O(n3)
Splitting increases polygon count
Again, O(n3) worst case
- Advantages:
- No over-rendering
- Anti-aliases well - just recurse deeper to get sub-pixel information
- Disadvantage:
- Tests are quite complex and slow
http://en.wikipedia.org/wiki/View_frustum_culling
Rays
through
view plane
ethod
ting
View plane
Eye position