|
|
Nearly every graphics card on the market today supports a z-buffer; however, depending on the circumstances, using this depth buffer can have its drawbacks. When calculating the depth of a pixel, Direct3D will place the pixel somewhere in the z-buffer range (normally from 0.0f to 1.0f), but this placement is rarely uniform across the entire range. The ratio of the near and far plane directly affects the distribution pattern of your z-buffer.
For example, if your near plane is 1.0f, and your far plane is 100.0f, 90% of the range will be used in the first 10% of your depth buffer. If you had a large "outdoor" scene, it wouldn't be uncommon to have much larger far planes. In the previous example, if your far plane was 1000.0f, 98% of the range would be used in the first 2% of the depth buffer. This could cause "artifacts" on distant objects, which may or may not matter in your application.
Using a w-buffer depth buffer eliminates this problem, but has its own downfalls as well. It's possible for artifacts to appear on near objects rather than distant objects when using a w-buffer. Also, it's worth noting that there isn't as much support in graphics cards for w-buffers as there is for z-buffers.
One last comment on depth buffers. For greater performance when rendering using depth buffers, it's best to render items from front (highest z) to back (lowest z). During scene rasterization, Direct3D can quickly reject a pixel that is already occluded and skip the drawing completely. This is naturally not the case when we're rendering data with alpha components, but since we haven't gotten that far yet, we'll skip that until later.
|
|