Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Hidden surface, visible surface & hidden-surface removal problem:-

If two opaque objects are in the line of sight then the closer object will be visible and far object
will be hidden from viewer. The surface that are seen to the viewer is visible surface and surface that are
not visible is hidden surface. The surfaces that are blocked or hidden from view must be “removed” in
order to construct a realistic view of 3D scene. The identification and removal of such surfaces is known
as hidden-surface problem.

Depth Comparisons:-
The two points P1(x1,y1,z1) and P2(x2,y2,z2), does either point Obscure or in front of each other
depends on conditions

1. If P1 and P2 are on same line?


2. If not, a depth comparison decides which point is in front of other.

In orthographic parallel projection onto xy plane, P1 and P2 are on same projectors if x1=x2 and y1=y2. In
this case if z1<z2 then P1obscures P2. For perspective projection the calculations are more complex that
can be avoided by transforming all three-dimensional objects so that parallel projections of the
transformed object is equivalent to the perspective projection of the original object.

Z-Buffer Algorithm:-
A point in the display space is “seen” from pixel (x, y) if the projection of the point is scan converted to
this pixel. The Z-buffer algorithm essentially keeps track of the smallest z coordinate (also called the depth
value) of those points which are seen from pixel (x, y). Z-buffer is used to store these Z values.

Let Zbuf(x, y) denote the current depth value that is stored in the Z-buffer at pixel (x, y). Then working with
the (already) projected polygons P of the scene to be rendered.

The Z-buffer algorithm consists of the following steps.

1. Initialize the screen to a background color. Initialize the Z-buffer to the depth of the back
clipping plane. That is, set Zbuf(x,y)=Zback, for every pixel (x,y).
2. Scan-convert each (projected) polygon P in the scene and during this scan-conversion process,
for each pixel (x,y) that lies inside the polygon:
(i.) Calculate Z(x,y), the depth of the polygon at pixel (x,y).
(ii.) If Z(x,y)<Zbuf(x,y), set Zbuf(x,y)= Z(x,y) and set the pixel value at (x, y) to the color of the
polygon P at (x, y). In the following figure points P1 and P2 are both scan-converted to
pixel (x, y); however, since z1<z2, P1 will obscure P2 and the z value at P1 i.e. z1, will be
stored in the Z-buffer.

Remark: The Z-buffer algorithm requires Z-buffer memory storage proportional to the number of pixels
on the screen.
References:

• Donald Hearn and M. Pauline Baker, “Computer Graphics C Version‟, Prentice – Hall of India

• Zhigang Xiang and Roy A Plastok, “Computer Graphics” Tata McGraw Hill Education Private
Limited, Second Edition

You might also like