Public Group

# [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.

## 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 on other sites
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.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633295
• Total Posts
3011245
• ### Who's Online (See full list)

There are no registered users currently online

×