Skip to main content
gamedev.net
🔒 Locked

Buffer formats

Started by Felipe_Ribas 1 reply 350+ views
Original Post
Felipe_Ribas
Felipe_Ribas
Hello, does anyone here can explane to me how buffer formats really works? My 3D model had some imperfections when rendering, then I figured out that i have to put D3DFMT_D24X8 insted D3DFMT_D16. I know that I added 8 bits to the depth buffer, but what did really changed? Why it wasnt capable to make a perfect rendering with only 8 bits? What kind of information does it store in the depth buffer? And what about stencil? What kind of information doest it store in stencil buffer? Does 8 bits per pixel can do the trick? How can I always know how much bits per pixel is enough to deph and stencil buffer?
ET3D
ET3D
I'd suggest that you read "Depth Buffers" and "Stencil Buffer Techniques" in the DirectX docs (I could only find the latter in the C++ docs, not the managed docs). You might want to search the web for more articles.

The short of it is, stencil buffers are used for specific techniques. You don't have to use them, and probably shouldn't for a start. A depth buffer is a must for keeping occlusions correct when rendering. The more bits it has, the better it can distinguish between pixels (of different objects) of nearby depth. When it can't do that well, you can get what is called "z fighting".

The accuracy of the depth buffer is affected not only by the number of bits, but also by the Z range (near and far view planes) that you set in your projection transform.

These days there's rarely a reason to use 16 bit depth, and cards don't usually support more than 24 bits, so 24 bits in the standard.
Namethatnobodyelsetook
Namethatnobodyelsetook
The further you can push out the near clipping plane in your projection matrix, the better the Z resolution will be for every depth value. The math is a bit complicated to explain, but the depth buffer holds a value that is 0 when at the near plane, 1 at the far plane. Between the two it ramps up to almost 1 very, very quicky, leaving very little precison left for the remaining 98% of the Z range. The near plane affects how quickly it ramps up much more than any thing else.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.