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-fighting 252<br />

Z-fighting<br />

Z-fighting is a phenomenon in <strong>3D</strong> rendering that occurs when two or<br />

more primitives have similar values in the z-buffer. It is particularly<br />

prevalent with coplanar polygons, where two faces occupy essentially<br />

the same space, with neither in front. Affected pixels are rendered with<br />

fragments from one polygon or the other arbitrarily, in a manner<br />

determined by the precision of the z-buffer. It can also vary as the<br />

scene or camera is changed, causing one polygon to "win" the z test,<br />

then another, and so on. The overall effect is a flickering, noisy<br />

rasterization of two polygons which "fight" to color the screen pixels.<br />

This problem is usually caused by limited sub-pixel precision and<br />

floating point and fixed point round-off errors.<br />

The effect seen on two coplanar polygons<br />

Z-fighting can be reduced through the use of a higher resolution depth buffer, by z-buffering in some scenarios, or by<br />

simply moving the polygons further apart. Z-fighting which cannot be entirely eliminated in this manner is often<br />

resolved by the use of a stencil buffer, or by applying a post transformation screen space z-buffer offset to one<br />

polygon which does not affect the projected shape on screen, but does affect the z-buffer value to eliminate the<br />

overlap during pixel interpolation and comparison. Where z-fighting is caused by different transformation paths in<br />

hardware for the same geometry (for example in a multi-pass rendering scheme) it can sometimes be resolved by<br />

requesting that the hardware uses invariant vertex transformation.<br />

The more z-buffer precision one uses, the less likely it is that z-fighting will be encountered. But for coplanar<br />

polygons, the problem is inevitable unless corrective action is taken.<br />

As the distance between near and far clip planes increases and in particular the near plane is selected near the eye,<br />

the greater the likelihood exists that you will encounter z-fighting between primitives. With large virtual<br />

environments inevitably there is an inherent conflict between the need to resolve visibility in the distance and in the<br />

foreground, so for example in a space flight simulator if you draw a distant galaxy to scale, you will not have the<br />

precision to resolve visibility on any cockpit geometry in the foreground (although even a numerical representation<br />

would present problems prior to z-buffered rendering). To mitigate these problems, z-buffer precision is weighted<br />

towards the near clip plane, but this is not the case with all visibility schemes and it is insufficient to eliminate all<br />

z-fighting issues.

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

Saved successfully!

Ooh no, something went wrong!