Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Mikvix

Death buffer

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

Hi, I''ve a problem with the z-buffer ... I''m drawing a landscape like in NeHe''s tutorial 35, with a sort of sea (a plane that is cutting the landscape). But .... the intersections of the landscape and the sea are very bad-looking ! I tried to change the values of z-far / z-near but I have not a good result ... the landscape'' coordinates are : z = [-128,128], x = [-128,128], y = [0,256] the sea'' : x = [-2000,2000], x = [-2000, 2000], y = [0,10]

Share this post


Link to post
Share on other sites
Advertisement
What are the values you pass to gluPerspective() and more important, to glDepthRange() ?

What 3D card do you have ?

Share this post


Link to post
Share on other sites
And what color depth do you use ? (16bpp or 32bpp)

And how many bits does your depth buffer have ?
(call glGetIntegerv(GL_DEPTH_BITS, &depth_bits) and print ''depth_bits'')

Share this post


Link to post
Share on other sites
depth_bits => 16 bits
bpp => 16 bits
3d card : Radeon VE (boooo)
gluPerspective() => I didn''t use it ... Should I ?

glDepthRange() : I tried a lot of values ... for z-near, I usually puts it to 0, but I heard that I must set it to 1 ... but when it is set to 1, the z-buffer doesn''t work at all (the pixels that appears are the last ones that I draw).
for z-far, I tried some values from 1 to 30000 ...

Thanks for your help

Share this post


Link to post
Share on other sites
quote:

depth_bits => 16 bits


First part of the problem.

quote:

gluPerspective() => I didn't use it ... Should I ?


Not necessarily. You use glFrustum instead ? What values do you use there ?

quote:

glDepthRange() : I tried a lot of values ... for z-near, I usually puts it to 0, but I heard that I must set it to 1 ... but when it is set to 1, the z-buffer doesn't work at all (the pixels that appears are the last ones that I draw).
for z-far, I tried some values from 1 to 30000 ...


Any value for znear below 1 is usually deadly for the zbuffer. 0 isn't even defined, and will yield unpredictable results.

You should try something like znear=1.0f and zfar=10000.0f . That should work pretty well with a 16bit depth buffer. You can then gradually adjust the far plane, to get the results you want. But don't make znear <1, if not absolutely necessary ! You can even try to make it a bit larger, if that does not introduce rendering problems. The zfar value isn't that critical, but a good znear value is crucial, especially with only 16bit depth buffer precision.

Edit: just to prevent misunderstandings: the above values for znear / zfar are for use as frustum planes for glFrustum/gluPerspective, and not for glDepthRange !

[edited by - Yann L on March 19, 2002 4:46:47 PM]

Share this post


Link to post
Share on other sites
ouch !
16-bits depth buffer is not enough

Try with 24-bits or 32-bits depth buffer and that should be better !

About depth range, use glDepthRange(0,1) if you can. (You can''t if you use specific depth effects, which I personnaly doubt about)

And don''t set the z-near to zero !
btw, what''s "z-near" for you ? is it the parameter you use into glDepthRange ? If so, then you''re wrong.

Share this post


Link to post
Share on other sites
Oow !

When I was talking about z-near/z-far, it was for the glDepthRange() values !!!!

So I have to use glFrustum ! I will try it ...

Thanks !!

Share this post


Link to post
Share on other sites
glDepthRange values are clamped to [0,1]
Yes you have to use glFrustum for a perspective projection matrix.
Use glOrtho for an orthographic projection.

Share this post


Link to post
Share on other sites
I think you're asking too much for a 16bits depth buffer.
Set the z-near to 1 or even to 0.2 or 0.5 if 1 is too much.

Which unit do you use ? the meter ?
[0.1f -> 10000.0f] represents [10cm -> 10km] ?
If so, are you sure you will see objects/terrain 10 kilometers away, and are you sure that you'll need to see objects close to the camera at 10cm ?

And please note that it gives better result to multiply the z-near by 10 than dividing the z-far by 10

[edited by - vincoof on March 20, 2002 7:16:01 AM]

Share this post


Link to post
Share on other sites

  • 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!