Hidden Surface Elimination
Instructor: Christopher Rasmussen (cer@cis.udel.edu)
April 12, 2022 ❖ Lecture 16
Outline
Clipping: Basic issues
from E. Angel
Cohen-Sutherland 2-D line clipping (not in textbook)
VA
xmin
xmax
ymax
ymin
adapted from F. Pfenning
y < ymax
y > ymin
x > xmin
x < xmax
= ∩
Cohen-Sutherland clipping: Outcodes
from Hill
Cohen-Sutherland clipping
from Hill
Cohen-Sutherland clipping
adapted from E. Angel
Cohen-Sutherland: Algorithm
compute outcodes
compute intersection
Computing the intersection point
adapted from Hill
Δx
Δy
c
a
b
xmin
xmax
ymax
ymin
Computing the intersection point
adapted from Hill
Δx
Δy
c
a
b
xmin
xmax
ymax
ymin
Computing the intersection point
adapted from Hill
Δx
Δy
c
a
b
xmin
xmax
ymax
ymin
Computing the intersection point
adapted from Hill
Δx
Δy
c
a
b
xmin
xmax
ymax
ymin
Line clipping: Notes
from E. Angel
from Hill
Clipping Triangles
courtesy of L. McMillan
Keep complete triangle
Throw away complete triangle
Keep triangular portion inside
Split quadrilateral portion inside into 2 triangles
Hidden Surfaces: Why care?
from Angel
Wireframe Hidden Line Removal
Backface Culling
from
Hill
n
Backface Culling on wireframe
from geometricalgebra.org
Polygon normals
n = (v1 - v0) x (vn - 1 - v0)
v0
v1
v2
v3
v4
Polygon normals
n = (v1 - v0) x (vn - 1 - v0)
v0
v1
v2
v3
v4
n
Backface culling: Test
v = p – eye in world coordinates
from
Hill
n
Backface culling: Test
v = p – eye in world coordinates
from
Hill
n
n
Depth tests for HSE
courtesy of Brent Haley
Z-buffering
from Hill
Z-buffer: Example
courtesy of DAM Entertainment
Color buffer
Depth buffer
Z-buffer: another example
courtesy of Brent Haley
Z-buffering
from Hill
Is this sorting?
Z-buffer: Implementation
Bilinear interpolation for DEPTH
m = lerp(mleft, mright, t)
mleft= lerp(m3, m4, tleft)
mright= lerp(m1, m2, tright)
Z-buffer precision
courtesy of SGI
Z fighting example
Z fighting example
video courtesy of Udacity
Z-buffering: Notes
Z-buffering in OpenGL
E.g., in HW #2 multiearth main.cpp
Painter’s algorithm
from Shirley
Draw primitives
from back to
front to avoid
need for depth
comparisons
Painter’s algorithm
from Angel
• Cyclical overlaps and interpenetration can be a problem