Sign in to follow this  

W-buffering?

This topic is 4339 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

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
Guest Anonymous Poster
Quote:
Original post by Demus79
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.


With any complicated scene you are going to run into the problem of objects crossing the layer. Even if it's quite minimal you can't simple ignore it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
Quote:
Original post by Demus79
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.


With any complicated scene you are going to run into the problem of objects crossing the layer. Even if it's quite minimal you can't simple ignore it.


I just explained that crossing the layer isn't so big deal unless the objects are related somehow with another object which is in the other layer (you know, the situation which the painter's algorithm cannot handle).

What would be your approach to render a terrain with visibility up to 10 kilometers ?

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
With any complicated scene you are going to run into the problem of objects crossing the layer. Even if it's quite minimal you can't simple ignore it.

Multiple layer zbuffers are only useful at very large distances. And usually, small objects struggling the border can be ignored, since the visible projective size of a possible error is very small (especially with regular chunk based geometry, such as terrains).

Large objects crossing the layer boundary can be rendered twice, once in each layer. This will not lead to additional overdraw, since the near/far clipping planes will correctly separate the object parts in both layers.

Share this post


Link to post
Share on other sites
Quote:
Original post by Drilian
it's the ratio between the two values (near and far plane distances) that determines the way the Z values are distributed


Not exactly. The thing that matters most is the ratio of the distance to the object you're rendering to the distance of the near plane, because the depth is given by something like:

Projected Z = ((Far + Near)*Z + 2*Far*Near) / (Far - Near) / Z

(This is for GL, so note that Z=-Far means on the far plane and the same for the near plane). Taking the derivative w.r.t Z:

d(Projected Z)/dZ = -2*Far*Near / (Far - Near) / Z^2

So if Far>>Near then basically the accuracy depends on where the near plane is, and the far plane can be moved away to infinity without impacting accuracy that much up to where it was before. The layering technique works because the object to near plane ratio is improved, not the far to near ratio.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Yann L
Quote:
Original post by Anonymous Poster
With any complicated scene you are going to run into the problem of objects crossing the layer. Even if it's quite minimal you can't simple ignore it.

Multiple layer zbuffers are only useful at very large distances. And usually, small objects struggling the border can be ignored, since the visible projective size of a possible error is very small (especially with regular chunk based geometry, such as terrains).

Large objects crossing the layer boundary can be rendered twice, once in each layer. This will not lead to additional overdraw, since the near/far clipping planes will correctly separate the object parts in both layers.


This is assuming that the far plane clips correctly, which isn't always the case with all hardware.

Share this post


Link to post
Share on other sites

This topic is 4339 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this