Page 116 - DCAP313_LAB_ON_COMPUTER_GRAPHICS
P. 116
Lab on Computer Graphics
Notes In displaying in a display box we proceed so that we transfer every object into a raster form. In
this way, we obtain points with the coordinates x, y a z. Because the display box is only two-
dimensional, the objects which are overlapped should not be visible. The Z-buffer serves also
to avoid the situation where more distant objects are drawn last and in this way overlap objects
standing closer to the observer.
We put into the field all z-coordinates of the relevant points of the given objects. If during the
test of a new point we found out that in the field there is a different value than the starting,
then, providing the new value is lower.
A disadvantage of the Z-buffer is its memory demand. The line scanning algorithm reduces
memory demands of storage as here it is necessary to store only a field equal to one horizontal
line of the screen. This method is based on the decomposition of a polygon into raster form.
Here, however, it is necessary to carry out the raster decomposition several times. For each row
of the display box we test every surface in a scene, using the given field as a depth memory.
An example of the algorithm as described.
Algorithm
• For every image point (x, y) we initialize the Z-buffer to the value of max as well as the
bitmap of background.
• For every surface we assign in the project a polygon; and carry out its decomposition into
a raster form, while for every image point of polygon (x, y) we assess a z-coordinate.
• If the distance of a given pixel (x, y) is lower than the Z-buffer of the relevant pixel, then,
we put the value of the given point into the Z-buffer and the colour of the point into the
bitmap
The order of processed polygons can be any, with every surface being processed only once. This
method is hardware implemented in all 3D cards (depth of 16, 24, or 32 bits).
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?
Z-buffer Analysis
Categorization:
• Easy to implement.
• Hardware implementation.
• Memory intensive.
• Incremental drawing calculations (uses coherence).
• Pre-processing required.
• On-line (does not need all objects before drawing begins).
• Handles transparency.
• Handles refraction.
• Polygon-based.
• Extra work for moving objects.
110 LOVELY PROFESSIONAL UNIVERSITY