07.01.2013 Views

3D graphics eBook - Course Materials Repository

3D graphics eBook - Course Materials Repository

3D graphics eBook - Course Materials Repository

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Z-buffering 248<br />

Z-buffering<br />

In computer <strong>graphics</strong>, z-buffering is the management of image depth<br />

coordinates in three-dimensional (3-D) <strong>graphics</strong>, usually done in<br />

hardware, sometimes in software. It is one solution to the visibility<br />

problem, which is the problem of deciding which elements of a<br />

rendered scene are visible, and which are hidden. The painter's<br />

algorithm is another common solution which, though less efficient, can<br />

also handle non-opaque scene elements. Z-buffering is also known as<br />

depth buffering.<br />

When an object is rendered by a <strong>3D</strong> <strong>graphics</strong> card, the depth of a<br />

generated pixel (z coordinate) is stored in a buffer (the z-buffer or<br />

depth buffer). This buffer is usually arranged as a two-dimensional<br />

array (x-y) with one element for each screen pixel. If another object of<br />

the scene must be rendered in the same pixel, the <strong>graphics</strong> card<br />

compares the two depths and chooses the one closer to the observer.<br />

The chosen depth is then saved to the z-buffer, replacing the old one.<br />

In the end, the z-buffer will allow the <strong>graphics</strong> card to correctly<br />

Z-buffer data<br />

reproduce the usual depth perception: a close object hides a farther one. This is called z-culling.<br />

The granularity of a z-buffer has a great influence on the scene quality: a 16-bit z-buffer can result in artifacts (called<br />

"z-fighting") when two objects are very close to each other. A 24-bit or 32-bit z-buffer behaves much better,<br />

although the problem cannot be entirely eliminated without additional algorithms. An 8-bit z-buffer is almost never<br />

used since it has too little precision.<br />

Uses<br />

Z-buffer data in the area of video editing permits one to combine 2D video elements in <strong>3D</strong> space, permitting virtual<br />

sets, "ghostly passing through wall" effects, and complex effects like mapping of video on surfaces. An application<br />

for Maya, called IPR, permits one to perform post-rendering texturing on objects, utilizing multiple buffers like<br />

z-buffers, alpha, object id, UV coordinates and any data deemed as useful to the post-production process, saving time<br />

otherwise wasted in re-rendering of the video.<br />

Z-buffer data obtained from rendering a surface from a light's POV permits the creation of shadows in a scanline<br />

renderer, by projecting the z-buffer data onto the ground and affected surfaces below the object. This is the same<br />

process used in non-raytracing modes by the free and open sourced <strong>3D</strong> application Blender.<br />

Developments<br />

Even with small enough granularity, quality problems may arise when precision in the z-buffer's distance values is<br />

not spread evenly over distance. Nearer values are much more precise (and hence can display closer objects better)<br />

than values which are farther away. Generally, this is desirable, but sometimes it will cause artifacts to appear as<br />

objects become more distant. A variation on z-buffering which results in more evenly distributed precision is called<br />

w-buffering (see below).<br />

At the start of a new scene, the z-buffer must be cleared to a defined value, usually 1.0, because this value is the<br />

upper limit (on a scale of 0 to 1) of depth, meaning that no object is present at this point through the viewing<br />

frustum.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!