Jump to content
  • Advertisement
Sign in to follow this  
Rapthor

ZBuffer being ignored

This topic is 4861 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there, I got a big problem: Although adding following lines into my c# code, my objects are not displayed correctly concerning the Depth Buffer, that should work with these settings: pres.SwapEffect = SwapEffect.Discard; pres.EnableAutoDepthStencil = true; pres.AutoDepthStencilFormat = DepthFormat.D16; .... device.RenderState.CullMode = Cull.Clockwise; device.RenderState.ZBufferEnable = true; device.RenderState.ZBufferWriteEnable = true; Of course I am clearing my device after having rendered one frame at a time: device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, Color.Bisque, 1.0F, 0); Why doesn't it work for me? I got DirectX SDK April 2005 and Visual Studio .NET 2003 Pro. Thanks in advance, Rapthor

Share this post


Link to post
Share on other sites
Advertisement
What are your viewport settings? Good values for MinZ and MaxZ are 1.0f and 1000.0f.

Often folks make their minz too small, thus killing their precision.

Also, I assume that your z compare function is less or lessequal?

Share this post


Link to post
Share on other sites
Do you maybe need CounterClockwise culling? I'm assuming you've tried it, but culling the wrong way might make it seem like z-buffering problems.

Share this post


Link to post
Share on other sites
WOW it works! It was the Matrix.PerspectiveFovLH()-setting.
zNear was 0f and far was 18f ... I changed it: near = 1 and far = 1000.

Thank you very much SimmerD.

Here the pictures BEFORE solving the problem.


The scene from side view (to show you the positions of my 2 objects):

http://mitglied.lycos.de/rapthor/other/sideview.JPG

Viewing from right (everything seems to be still alright):

http://mitglied.lycos.de/rapthor/other/fromright.JPG

And now the disgusting view from left:

http://mitglied.lycos.de/rapthor/other/fromleft.JPG

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!