# z culling not working properly on some fragments

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

## Recommended Posts

Hi,Sometimes some fragments behind others are displayed :

[attachment=6017:buggy.PNG]

behind the 'tree' there's a box wall like this one :

[attachment=6018:wall.PNG]

I tried with another video card (GeForce GT530) and there wasn't this bug at all.
My video card drivers have been updated yesterday. It's a GeForce 9500GT

I suspect my gpu to be faulty

thanks

##### Share on other sites
Hidden
Check your images, I cant see them ;-)

-

##### Share on other sites

Check your images, I cant see them ;-)

Hello
Done

##### Share on other sites

How do you clean your z-buffer?

for each frame, before the draw calls :
 g_pd3dDevice->ClearDepthStencilView(g_pDepthStencilView,D3D10_CLEAR_DEPTH,1.0f,0); 

I would also add that it occurs very very rarely (and randomly)

##### Share on other sites

How do you clean your z-buffer?

for each frame, before the draw calls :
 g_pd3dDevice->ClearDepthStencilView(g_pDepthStencilView,D3D10_CLEAR_DEPTH,1.0f,0); 

I would also add that it occurs very very rarely (and randomly)
[/quote]

What are your near and far plane values?

Are you using any alpha transparency for the objects?

##### Share on other sites
I checked on another computer and the problem never occured
zNear=0.1
zFar=10000.0

I just tried zFar=1000.0 but the problem was still there

I use alpha testing in a specific shader, not in general
the boxes of the walls are using it

-

##### Share on other sites

I checked on another computer and the problem never occured
zNear=0.1
zFar=10000.0

I just tried zFar=1000.0 but the problem was still there

I use alpha testing in a specific shader, not in general
the boxes of the walls are using it

Regardless of the bug, you should always set your zNear to as big as you can and zFar only as far as required. 0.1 : 10000 ratio is quite big.
Otherwise this kind of bug is difficult to debug and you may have reason that you have faulty GPU.

Good luck!

##### Share on other sites
A zNear value of 1.0 is the standard as far as I know, I would try that with a zFar of 1000.0 (if that doesn't cut into your scene). Also, what AutoDepthStencilFormat are you using with your presentation parameters when you create your device? I've had much better results with 24-bit depth buffers (D3DFMT_D24S8) than with what most tutorials set you up with - which is a 16-bit buffer most of the time. If you use 1.0/1000.0 and D3DFMT_D24S8 and you're still getting that problem it's not a z-fighting issue after all...

##### Share on other sites

A zNear value of 1.0 is the standard as far as I know, I would try that with a zFar of 1000.0 (if that doesn't cut into your scene). Also, what AutoDepthStencilFormat are you using with your presentation parameters when you create your device? I've had much better results with 24-bit depth buffers (D3DFMT_D24S8) than with what most tutorials set you up with - which is a 16-bit buffer most of the time. If you use 1.0/1000.0 and D3DFMT_D24S8 and you're still getting that problem it's not a z-fighting issue after all...

No, Near plane one unit away is not normal, its just what you do - personally I set near plane to 0.1 ?

##### Share on other sites
The value for the near plane depends on your setup and the value itself can have impact on scale. a z-near of 1.0 can mean 'cull anything closer than a meter to the camera' which is clearly not right.
The last game I worked on had a z-near of 0.2 and a far of 333.3; there is no 'standard' value.

##### Share on other sites
Yes I misworded that, the point is that temporary upping the zNear to 1.0 (which is certain to give a good 'scale') is the best way to go about debugging the OP's problem.

##### Share on other sites
Thank you for your help !

I use a 32 bit depth buffer.
Now zNear=1.0 and zFar=1500. It looks like the bug less occurs