Changing Depth Buffer Write Access
By default, the Microsoft Direct3D system is allowed to write to the depth buffer. Most applications leave writing to the depth buffer enabled, but some special effects can be achieved by disabling this functionality in the Direct3D system.
To disable depth buffer writes in C#, set the RenderStateManager.ZBufferWriteEnable property of the Device.RenderState property to false. This is illustrated in the following C# code example.
[C#]
using System;
using Microsoft.DirectX.Direct3D;
// Declare a rendering device.
Device device = null;
// Initialize the device.
.
.
.
// Get the device's render state object.
RenderStates rs = device.RenderState;
// Disable depth buffer writes.
rs.ZBufferWriteEnable = false;
// Render the scene.
.
.
.
// Enable depth buffer writes
// (note the different syntax; both forms are acceptable)
device.RenderState.ZBufferWriteEnable = true;