Jump to content
  • Advertisement
Sign in to follow this  
ninjaindark

[MDX] A problem about depth buffer

This topic is 4825 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 am new to DirectX and currently reading the book "Managed DirectX® 9 Kick Start: Graphics and Game Programming" by Tom Miller. In his book I can't under stand an example he gives in Chapter 1, part 4 about depth buffer. Can anyone briefly explain it for me? --------------------- Nearly every graphics card on the market today supports a z-buffer; however, depending on the circumstances, using this depth buffer can have its drawbacks. When calculating the depth of a pixel, Direct3D will place the pixel somewhere in the z-buffer range (normally from 0.0f to 1.0f), but this placement is rarely uniform across the entire range. The ratio of the near and far plane directly affects the distribution pattern of your z-buffer. For example, if your near plane is 1.0f, and your far plane is 100.0f, 90% of the range will be used in the first 10% of your depth buffer. If you had a large "outdoor" scene, it wouldn't be uncommon to have much larger far planes. In the previous example, if your far plane was 1000.0f, 98% of the range would be used in the first 2% of the depth buffer. This could cause "artifacts" on distant objects, which may or may not matter in your application. --------------------- Thanks Ray

Share this post


Link to post
Share on other sites
Advertisement
What it is saying is that the depth buffer has limited resolution and two objects at different distances may have the same value in the depth buffer. The result is that even if object A is behind object B, object A may be drawn in front because they have the same depth buffer value. The resolution is lower is greater distances, so the problem is more common with distant objects.

The resolution of the depth buffer depends mostly on the distance to the near plane and some on the distance to the far plane. As a result, you should place the near plane as far from the camera as you can for maximum resolution. A common rule of thumb is that the near plane should be at least 1/1000th of the way to the farthest object to be displayed. Thus, if your farthest object is 1000 meters away, the near plane should be at least 1 meter away to avoid problems displaying that object.

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!