Hidden Surface Removal - Computer Graphics
Hidden Surface Removal - Computer Graphics
Hidden Surface Removal - Computer Graphics
• Visible surfaces
• Parts of a scene visible from chosen viewpoint
• Hidden surfaces
• Parts of a scene not visible from chosen viewpoint
• Subtle difference between hidden surface
removal and visible surface determination
• Many algorithms: image space, object space
and hybrid.
• Requirements for quality vs. speed.
1
Hidden Surface Algorithms
Object-space
Image-space
• Decide on visibility
at each pixel position
2
Reducing complexity
Exploit Coherence
• Object Coherence: If objects are well
separated, compare objects not faces.
Reducing complexity
• Area Coherence: Groups of
adjacent pixels often covered by
the same visible face.
3
Back-Face Removal
back-face culling
• We see a polygon if its normal is pointed toward
the viewer.
Plane equations
Finding Polygon Normals
Ax + By +Cz + D = 0
n = (Q-R) X (Q-P)
4
Plane Equation
Plane equation : Ax + By +Cz + D = 0
Expanding:
A = y1(z2-z3)+y2(z3-z1)+y2(z3-z1)
etc.
5
Back face culling
• object is (approximated by) a solid polyhedron
=> faces completely enclose its volume
6
Depth sort
Or painters algorithm
• determine a visibility ordering for objects which will
ensure a correct picture if objects are rendered in that
order
Depth sort
tests for visibility:
1. do x or y -extents not overlap?
2. is S entirely on the opposite side of S’
plane, from the viewpoint?
3. is S entirely on the same side of S’
plane, from the viewpoint?
4. do the projections of polygons onto the
xy plane not overlap?
7
Z-buffer method
• A commonly used image-space approach to
hidden-surface removal
• It is also referred as Depth-Buffer method
• Use the intensity color of the nearest 3D point
for each pixel
What is an efficient way for it?
• 2 buffers,
• frame buffer – stores image information
• z-buffer – depth information
• with the same resolution
8
Z-Buffer Algorithm
for all positions (x,y) in the view screen
frame(x,y)=I_background
depth(x,y)=max_distance
end
for each polygon in the mesh
for each point(x,y) in the polygon-fill algorithm
compute, z, the distance of corresponding 3D-point from COP
if depth(x,y) > z // a closer point
depth(x,y)=z
frame(x,y)=I(p) //shading
endif
endfor
endfor
Determining Z-Depth
If we have the plane equation:
Ax + By +Cz + D = 0 Normal Vector: N=(A, B, C)
So incrementing:
zi +1 = zi - a/c across scan line
zj +1 = zi j - b/c between scanlines
9
Z-buffer Alternative method
After the algorithm
• Frame buffer contains intensity values of the visible
surface
• z-buffer contains depth values for all visible points
Alternative method for computing z-depth the step in
algorithm
• We know d 1 , d2, d 3 and d 4 from vertices of the mesh
• Use linear interpolation for other points d4
d1
d3
d2
• Transparency?
10