   Linear depth projection
  Has anyone been able to successfully implement linear depth projection similar to the one described at this link?I understand the concept and have incorporated the authors suggestion of pre-multiplying by the homogoneous clip space w (to negate the post-transform divide) and dividing by the far plane distance (separately in both the vshader and projection matrix) in a demo program but it doesn't appear to work. I end up getting very weird depth sorting artifacts and even weirder geometry popping issues (as if they were clipped or early z-rejected, due to improper depth).Any insights would be greatly appreciated. Thanks!   
  Yes worked fine for me on my last engine, you just have to remember munge the Z-value into a W-friendly format whenever it is accessed (e.g. in your fog calculation).Did you enable w-buffer in the hardware ?  On directx this done as described here:http://www.mvps.org/directx/articles/using_w-buffers.htm lpDevice->SetRenderState(D3DRENDERSTATE_ZENABLE,D3DZB_USEW);;  I think the original article about this is by Stefan Brabec "Practical Shadow Mapping"... you might check out this one. I also covered this in "Programming Vertex and Pixel Shaders".Here is the source of the vertex shader (... from the top of my head ... might not compile):float4 Position = mul(Pos, mLightViewProj);...Out.Depth = ((Position.z + fNear) / (fFar - fNear));Out.Pos.z = Out.Depth * Position.w;Have fun,- wolf   ;  griffin2000: Uh, I believe that link explains how to use the z-buffer to provide a linear depth projection. He explicitely states that w-buffer support is dropping off so he shows how to do it using a vertex shader. So, no, I don't enable w-buffer (nor do I want to). :-)wolf: That paper is an excellent read, thanks for the tip. I tried outputting the z and depth as you suggested and although it appears to work I'm not getting the results I was hoping for when manipulating the final depth in the pixel shader (this is for a nailboard implemention). I'll keep working on it but thanks for the  advice thus far.   ;Quote:Original post by griffin2000Did you enable w-buffer in the hardware ?  W buffers are obsolete, you shouldn't use them anymore (at least if you want to be future proof).   