View Full Version : Z vs. W buffer
04-18-2000, 09:42 AM
I read a few days ago that the Z and W buffers are basically used for the same thing, namely depth testing. This source also stated the main difference is how the depth planes are divided (more linear divide with the W buffer.) I also know that the Z buffer is supported by more hardware. So I thought that the Z buffer is usually better. But I just saw a demo with the Z and W buffers implemented in directX and the W buffer implementation looked a lot better. So what gives? Which one is really better and in which cases? Any insight on this matter would be great.
04-18-2000, 11:54 AM
Don't know anything about this, just speculating wildly based on your description :-)
Traditional Z-buffers are float-based, which means they're very precise at close ranges but sometimes show artifacts ("Z-fighting") with almost-coplanar polys at longer ranges.
If W-buffers are more linear, it sounds as if they're more like fixed-point, and will have the same precision anywhere in your viewing frustrum. So compared to Z-buffers you lose some precision at close range, and gain it at longer range.
I can see that this might look better in some circumstances. HOWEVER, as with so much else these days, this only makes sense in small, enclosed, claustrophobic Quake-like environments. The deeper your frustrum, the more each fixed-point W value gets stretched, and the worse your precision gets EVERYWHERE. In a really huge outdoor environment I can see W-precision being in the order of metres, at which point it becomes pretty much useless.
In any sensible LOD scheme, geometry should be getting bigger as you get further away, and IMHO depth-buffering should reflect this.
[This message has been edited by MikeC (edited 04-18-2000).]
04-18-2000, 01:42 PM
Well, I looked a bit into it.
While a z-buffer is a linear represantion of an depth value, a w-buffer is not.
It's like gouraud shading, it is almost looking okay, but it is not correct mathematical (it is not taking the perception into account).
At the end it is on our own to decide, like between an CD track and a "good old" long play record. I (personaly) prefer the long play reccord, because its sound creat).
And may the vector be with you!
04-18-2000, 06:55 PM
Here is an excerpt from the DirectX6 docs on the matter:
"Nearly all 3-D accelerators on the market support z-buffering, making z-buffers the most common type of depth buffer today. However ubiquitous, z-buffers do have their drawbacks. Due to the mathematics involved, the generated z values in a z-buffer tend not to be distributed evenly across the z-buffer range (typically 0.0 to 1.0, inclusive). Specifically, the ratio between the far and near clipping planes strongly affects how unevenly z values are distributed. Using a far-plane distance to near-plane distance ratio of 100, 90% of the depth buffer range is spent on the first 10% of the scene depth range. Typical applications for entertainment or visual simulations with exterior scenes often require far plane/near plane ratios of anywhere between 1000 to 10000. At a ratio of 1000, 98% of the range is spent on the 1st 2% of the depth range, and the distribution gets worse with higher ratios. This can cause hidden surface artifacts in distant objects, especially when using 16-bit depth buffers (the most commonly supported bit-depth).
A w-based depth buffer, on the other hand, is often more evenly distributed between the near and far clip planes than z-buffer. The key benefit is that the ratio of distances for the far and near clipping planes is no longer an issue. This allows applications to support large maximum ranges, while still getting relatively accurate depth buffering close to the eye point. A w-based depth buffer isn't perfect, and can sometimes exhibit hidden surface artifacts for near objects. Another drawback to the w-buffered approach is related to hardware support: w-buffering isn't supported as widely in hardware as z-buffering."
04-18-2000, 07:50 PM
Thanks guys. I think I have a pretty good understanding of what is the difference now and when to use the Z verses W. Any further comments are welcome, but I think my original question has been answered. Thanks again.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.