Death buffer
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]
What are the values you pass to gluPerspective() and more important, to glDepthRange() ?
What 3D card do you have ?
What 3D card do you have ?
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'')
And how many bits does your depth buffer have ?
(call glGetIntegerv(GL_DEPTH_BITS, &depth_bits) and print ''depth_bits'')
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
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
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]
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.
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.
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 !!
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 !!
glDepthRange values are clamped to [0,1]
Yes you have to use glFrustum for a perspective projection matrix.
Use glOrtho for an orthographic projection.
Yes you have to use glFrustum for a perspective projection matrix.
Use glOrtho for an orthographic projection.
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]
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]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement