Jump to content
  • Advertisement
Sign in to follow this  
marrshal

Drawing near objects problem

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

When I draw object that supose to be realy close to each other I have results like those:
[attachment=7027:fail01.JPG]
[attachment=7030:fail02.JPG]

In this case the water is about 0.1f above the ground in the "problem" area. If I zoom in a lot the problem goes off. And if I zoom out the problem gets at much more areas:

[attachment=7029:fail03.JPG]

Do you know where the problem comes from? I think is somthing about the depth testing, but still can't fix it..

Thank you in advance!

Share this post


Link to post
Share on other sites
Advertisement
Yes its about depth testing.

You could:
-Move the water farther from the ground
-Cut a hold in the ground where the water is
-Draw terrain, then draw water with depth testing disabled, then everything else
-Adjust the far plane closer to the near plane

Share this post


Link to post
Share on other sites
More specifically, it's related to not having enough precision to your depth buffer.

There are a number of ways to increase effective depth buffer precision:

  • Make sure you are requesting the highest bit-depth buffer available (probably 32-bits).
  • Try placing the near/far planes closer together (possibly varying these by the distance to the terrain).
  • Try a floating-point depth buffer, or even a logarithmic one.

Share this post


Link to post
Share on other sites
Thank you very much for the answers. I have places near and far dist closer and i have separated the surfaces of the water and the ground, so the water plane and the ground plane are crossing, not overlapping as before. This fix the problem from the viewpoint of the player but if I'm looking with my global camera the problem is still there. @swiftcoder how can I check the bits of depth buffer I'm requesting? Everything I'm doing about my depth buffer is:


glEnable (GL_DEPTH);
glEnable (GL_DEPTH_TEST);

Share this post


Link to post
Share on other sites

-Adjust the far plane closer to the near plane


With a standard perspective projection matrix, the effective way to gain more precision over the depth range is to push the near plane as far from zero as possible, instead of bringing the far plane closer to the near plane. Cutting down the draw distance does little to improve precision for the remaining view distance.

If you are using very small near plane distances, like 0.01f, 0.1f, try pushing the near plane to 1.0f, 5.0f or even 10.0f, depending on your scale, and how close to objects your camera ever goes to.

Another solution is to linearize your depth buffer. This is a very good read.

Share this post


Link to post
Share on other sites

@swiftcoder how can I check the bits of depth buffer I'm requesting?

What toolkit are you using to create your window/OpenGL context? Depth buffer precision has to be specified as you create the context.

Share this post


Link to post
Share on other sites

[quote name='Marrshal' timestamp='1328391606' post='4909655']
@swiftcoder how can I check the bits of depth buffer I'm requesting?

What toolkit are you using to create your window/OpenGL context? Depth buffer precision has to be specified as you create the context.
[/quote]
This helps, I was using 16 bit depth buffer. :)

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!