Jump to content
  • Advertisement
Sign in to follow this  
cppcdr

W-buffering?

This topic is 4556 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I had heard somewhere that w-buffering was better than z-buffering. Is this true and if it is, what are the benefits?

Share this post


Link to post
Share on other sites
Advertisement
W-buffering has a more linear distribution of depth values than z-buffering. It is supposed to produce less depth artifacts (z-fighting etc.) than the z-buffer and allow a larger range between the near and far planes. As I understand it hardware support for w-buffering is rare (it may be somewhat deprecaed). Note also that it may require a special projection matrix.

The math discussed briefly at the bottom of this page.

Share this post


Link to post
Share on other sites
W-buffering was an acceptable alternative in the days of 16bit z-buffers, so to reduce medium distance z fighting artifacts. Today, with 24/32bit zbuffers, w-buffering will usually yield worse results than a plain old z-buffer. Especially near geometry will be badly affected.

A well defined near plane on a 24bit z-buffer will give you enough precision for even the most complex scenes. If you have extremely large distance viewing ranges, use a layered rendering approach.

Share this post


Link to post
Share on other sites
Quote:
Original post by cppcdr
How do you do layered rendering?

Well, you first render your very far away geometry. Then you clear the depth buffer. Finally, you render your medium to near geometry. You can add additional layers as needed.

Note that this is only required, if you have huge viewing distances, as in eg. a space sim game. For indoor, or common planetary scale outdoor scenes (eg. large terrains), a single 24bit zbuffer is usually fine.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
And how does repetively clearing your z-buffer help precision and z-fighting?

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
And how does repetively clearing your z-buffer help precision and z-fighting?

By clearing the depth-buffer each "layer" can use the full depth buffer precision.

Share this post


Link to post
Share on other sites
More specifically, if you render the SUPER-FAR range (say, 2000-200,000 world units) in the first pass, then 2000 becomes the Z-Buffer's 0.0, and 20,000 becomes the buffer's 1.0. Then you render the nearer stuff (1-2000), and now 1 is 0.0 in the zbuffer, and 2000 becomes 1.0.

Because it's the ratio between the two values (near and far plane distances) that determines the way the Z values are distributed, it is this ratio that contributes to z-fighting (though the scales of the objects plays a part as well). Rendering the 2000-200,000 range of Z-Values in one pass would give the same amount of z-fighting as rendering the 1-100 range (that is to say, not much at all - note that you can get very good results with even a 1-2000 range, so a 1:100 ratio is very good). rendering a full 1-200,000, however, would produce a ton of z-fighting, because of the large discrepancy between the near and far planes.

Obviously, if you have things that are very,very close together relative to the scales of the near/far plane, you're likely to see Z-Fighting regardless of the ratio, since that's basically what it is. But you should generally see fighting like that at any distance within the Z-buffer, not just farther away.

Sorry if this post is a bit rambling (and I'm only about 90% convinced of its factual accuracy), but I'm kinda tired. Hope it helps...apologies if it's just more confusing.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
How do you resolve correct z values between the layers? It will almost never work out that an entire object will be on one side of the layer. For most cases objects and triangles will strattle that line.

It doesn't seem clear to me how this solution can be possible.

Share this post


Link to post
Share on other sites
Perhaps you can do a sort for the object to see if it is considered as a far-layer object or near-layer object.

The Z-ranges for the layers don't need to be always the same for every frame.
So with the far-range objects you can do some bound box math to get approximate near plane distance to avoid object clipping. And the same calculation is needed for the farplane of the near-layer.

Yes, there is a problem if some objects are spatially related with the objects of the other layer. With terrain for example the problem is quite minimal since the terrain is usually made of chunks, which don't intersect any other chunks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!