Why does disabling the DepthBuffer cause my models to have holes?

Hi all,

I’ve got some models which I am drawing and I need to disable the DepthBuffer so that the models are drawn in the order I need.

To do this I did the following

private readonly DepthStencilState _DepthStencilState = new DepthStencilState()
{
    DepthBufferEnable = true,
    DepthBufferWriteEnable = true
};

GraphicsDeviceManager.GraphicsDevice.DepthStencilState = _DepthStencilState;

However the following code causes holes to appear in my models,

Here are some examples of my models with DepthBuffer Enabled:

And here are some examples with DepthBuffer Disabled:

Anyone have any idea what might be going on? Any guidance would be sincerely appreciated.

I dont see the holes or any difference between the images. If you disable the depth buffer, you must think about in what order each triangle render in the model, and the triangles on the backside of the model might render last and end up above.

Easier code to use is:
GraphicsDeviceManager.GraphicsDevice.DepthStencilState = DepthStencilState.None;

Even with it enabled you can still draw each model in whichever order you want.
If the normals are proper and you turn on cw or ccw culling.

To me it looks like the inside of the folds in the fabric is being drawn after the front of the folds.

So with depth buffer disabled, it will draw the front of the fabric, then draw the back of the fabric, overwriting the expected pixels with rubbish.

MaximG Nov '15

Hi all,

2 years later

StainlessTobii8h

To me it looks like the inside of the folds in the fabric is being drawn after the front of the folds.

So with depth buffer disabled, it will draw the front of the fabric,
then draw the back of the fabric, overwriting the expected pixels with
rubbish.

Ya it was probably a badly made model thats what i was thinking too.