zbuffer rendering problem

Hi I have an issue with may game.

I render the world and that works fine.
When I load up my building select menu it previews the building.
The problem is the depth buffer stops part of the building rendering.

Iv posted an image below.
Is there a way to clear the buffer / depth buffer?

as you can see the black parts are the where the world is interfering with the render.

Use GraphicsDevice.Clear. There’s an overload that takes ClearOptions which allows you to specify what to clear exactly. This way you can for example clear only the depth buffer by specifying ClearOptions.DepthBuffer.
The other overload that you’re probably more familiar with, GraphicsDevice.Clear(Color), clears depth buffer, stencil buffer and render target.

Edit: ClearOptions is a flags enum, so you can OR values to clear a combination of depth, stencil and target. E.g. pass ClearOptions.Depth | ClearOptions.Stencil to clear depth and stencil buffers, but not the render target.

1 Like

You my friend are a genius :slight_smile:
Worked like a charm. Thank you

1 Like

This worked for me

GraphicsDevice.Clear(ClearOptions.DepthBuffer, Color.TransparentBlack, 1f, 0);