New answers tagged depth-buffer
Indeed, the values stored in the z-buffer are not linear to the actual z coordinates of your objects, but to their reciprocal, in order to give more resolution to what's near the eye than to what's closer to the back plane. What you do is that you map your zNear to 0 and your zFar to 1. For zNear=1 and zFar=2, it should look like this The way to ...
1000/65536 == 0.0152587890625. Just use increments of 0.015 or maybe 0.015625, because it has accurate binary representation (2**(-6)). With the latter you'll get 1000/(2**(-6)) == 64000 unique positions.
Maybe you should change You'r approach to something simpler. What I would do; Keep your Z depth thing, but keep a list of what you render. Order that list based on the z Depth value, and render objects in the order of the list. Hope this can help. People always tell me to keep things simple.
The old DirectX SDK outlines a method for being able to do this, but it does require that you use Direct3D 9 Ex rather than just plain-old Direct 3D 9. Since 9 Ex is only available on Vista+ this may not suit your requirements. It's covered in the section titled Feature Summary (Direct3D 9 for Windows Vista) and I'll quote it in full: Reading ...
You can read the depth buffer in a pixel shader if you use one of the special formats described at http://aras-p.info/texts/D3D9GPUHacks.html. They are somewhat GPU vendor specific, but you can probably get away with just INTZ support. That lets you either do what you need to do on the GPU, or to use the shader to copy it to another render target that you ...
Top 50 recent answers are included