ZBuffer being ignored
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
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?
Often folks make their minz too small, thus killing their precision.
Also, I assume that your z compare function is less or lessequal?
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.
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement