Science  People  Locations  Timeline
Index: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Home > Z-buffering


 

Z-buffering is a term in computer graphics which refers to management of image depth coordinates in 3-d graphics hardware. It is one solution to the " visibility problem ," which is the problem of deciding which elements of a rendered scene are drawn in front, and which are hidden. Another common solution is called the " painter's algorithm."

When an object is rendered by a 3D graphics card, the depth of a generated pixel (z coordinate) is stored in a buffer (the z-buffer). This buffer is usually arranged as a two-dimensional array (x-y), one element for each screen pixel. If another object of the scene must be rendered in the same pixel, the graphics card compares the two depths and chooses the one closest to the observer. The chosen depth is then saved to the z-buffer, replacing the old one. In the end, the z-buffer will allow the graphics card to correctly reproduce the usual depth perception: a close object hides a farther one.

The granularity of a z-buffer has a great influence on the scene quality: an 8-bit z-buffer can result in artifacts when two objects are close to each other. A 16 or 32-bit z-buffer behaves much better.

Additionally, precision in the z-buffer distance values is not spread evenly over distance. Nearer values are much more precise (and hence can display closer objects more properly) than values which are farther away. Generally, this is desirable, but sometimes it will cause artifacts to appear as objects become more distant. A variation on z-buffering which results in more evenly distributed precision is called w-buffering .

At the start of a new scene, the z-buffer must be cleared to a defined value (usually zero).

On recent PC graphics cards (1999-2003), z-buffer management uses a significant chunk of the available memory bandwidth. Various methods have been employed to reduce the impact of z-buffer, such as lossless compression (compute resources to compress/decompress are cheaper than bandwidth), and fast z-clear (skipping inter-frame clear altogether using signed numbers to cleverly check depths: one frame positive, one frame negative).

1 The mathematics of z-buffering

The range of depth values in camera space (See 3D projection) to be rendered is often defined between a and value of . After a perspective transformation, the new value of , or , is defined by:


Where is the old value of in camera space, and is sometimes called or .

The resulting values of are normalize d between the values of -1 and 1, where the planeIn mathematics, a plane is the fundamental two-dimensional object. Intuitively, it may be visualized as a flat infinite piece of paper. Most of the fundamental work in geometry, trigonometry, and graphing is performed in two dimensions, or in other words, is at -1 and the plane is at 1. Values outside of this range correspond to points which are not in the viewing frustumpolyhedra A frustum is the portion of a solid (normally a cone or pyramid) which lies between two parallel planes cutting the solid. Degenerate cases are obtained for finite solids by cutting with a single plane only. An example of a pyramidal frustum may, and shoudn't be rendered.

To implement a z-buffer, the values of are linearly interpolatedLinear interpolation is a process employed in mathematics, and numerous applications thereof including computer graphics. It is a very simple form of interpolation. How to do linear interpolation You know the coordinates x y and x y . You want to pick poi across screen space between the verticesIn geometry, a vertex ( Latin: whirl, whirlpool; plural vertices is a corner of a polygon (where two sides meet) or of a polyhedron (where three or more faces and an equal number of edges meet). In graph theory, a graph describes a set of connections betw of the current polygonA polygon (from the Greek poly for "many", and gonos for "angle") is a closed planar path composed of a finite number of sequential straight line segments. The straight line segments that make up the polygon are called its sides or edges and the points wh, and these intermediate values are generally stored in the z-buffer in fixed pointComputer arithmetic See also fixed point (mathematics). In computing, a fixed-point number representation is a real data type for a number that has a fixed number of digits after the decimal (or binary or hexadecimal) point. For example, a fixed-point num format. The values of are grouped much more densely near the plane, and much more sparesly farther away, resulting in better precision closer to the camera. The closer the plane is set to the camera, the less precision there is far away -- having the plane set too closely is a common cause of undesireable rendering artifacts in more distant objects.

To implement a w-buffer, the old values of in camera space, or , are stored in the buffer, generally in floating pointComputer arithmetic A floating-point number is a digital representation for a number in a certain subset of the rational numbers, and is often used to approximate an arbitrary real number on a computer. In particular, it represents an integer or fixed-poi format. However, these values cannot be linearly interpolated across screen space from the vertices -- they usually have to be invertedInversion has different meanings in different fields of knowledge: Something that is inverted or the process by which an inverse is obtained. In music, see Inversion (music). In mathematics, there are several meanings: See Inversive geometry and permutati, interpolated, and then inverted again. The resulting values of , as opposed to , are spaced evenly between and .

Whether a z-buffer or w-buffer results in a better image depends on the application.



Read more »

Non User