Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

Depth/Z-Buffer Resolution Usage!

Started by mokhans Jul 2, 2004 at 3:17 AM 2 replies 500+ views
Original Post
mokhans
mokhans
> I'm using following line to set my Projection Matrix and Clipping Plane. > D3DXMATRIX matProjection; > ZeroMemory(&matProjection, sizeof(matProjection)); > > // Use D3DX to create a left handed cartesian Field Of View transform > D3DXMatrixPerspectiveFovLH(&matProjection,D3DX_PI/DivFactor, > g_D3DSettings.m_fScreenAspect,1.0,ROWSPACING*ROWS); > > Where ROWSPACING=8000 > ROWS=256 > DivFactor=4 > g_D3DSettings.m_fScreenAspect=1024/768 > > > When i changed Near Clipping plane to 100.0f > this strange behaviour is gone. And a person replied identifying the problem elegantly and it's solution as follows. Yes, this is definitely the issue here, because the distribution of your z-buffer resolution is determined by the ratio of the near to far planes. The distribution of z-values is not linear, rather being concentrated towards the near clipping plane. With the settings shown, you have a near of 1.0 and a far of 1:2,048,000, which is extreme. The result is that, given each row is 8000 wide, at a distance of one row you've already used up 99.9875% of your z-buffer resolution! Even with a 32 bit z-buffer, your resolution would approach your row size towards the last row. By increasing your near plane to 100, now you have reduced this ration to 1:20,480, providing much better distribution of your z-buffer resolution.. ------------------- I can't figure out that how he determine how much of the depth buffer resolution is used? Q-1)Please let me know how he has determined this value 99.9875%. Q-2)In DXSDK docs,They've used the ratio of far-plane/near-plane and you're using far-plane/near-plane ratio. I hope that Some D3D Expert will put some lite over it and make all of us understand it more.Thanks.Take Care. Owais.
mokhans
mokhans
THnaks for the reply.I'm currently reading this article,I'm quite sure that concepts presented in this article is also eligible to Direct3D.Lets see what we get.
mokhans
mokhans
Hi,
Thanks for the Z-Buffer article.I want to ask 2 questions.

1)Where do you get these formulas?.Is there any derivation of it?
2)When i opened the source of this web page,I see something strange.The variables "ZF" and "ZN" are passed into "zb()" and "zprec()" functions not properly."ZN" value is being passed as "ZFar" parameter."ZF" value is being passed as "ZNear" parameter.

Thanks,
Owais.

Topic Locked

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

Sign in to reply to this topic.