Platform SDK: DirectX

Using Z-Bias

Polygons that are coplanar in your 3-D space can be made to appear as if they are not coplanar by adding a z-bias to each one. This is a technique commonly used to ensure that shadows in a scene are displayed properly. For instance, a shadow on a wall will likely have the same depth value as the wall does. If you render the wall first, then the shadow, the shadow might not be visible, or depth artifacts may be visible. You could reverse the order in which you render the coplanar objects in hopes of reversing the effect, but depth artifacts are still likely.

[C++]

A C++ application can help ensure that coplanar polygons are rendered properly by adding a bias to the z-values that the system uses when rendering the sets of coplanar polygons. To add a z-bias to a set of polygons, call the IDirect3DDevice7::SetRenderState method just before rendering them, setting the dwRenderStateType parameter to D3DRENDERSTATE_ZBIAS, and the dwRenderState parameter to a value between 0-16 inclusive. A higher z-bias value will increase the likelihood that the polygons you render will be visible when displayed with other coplanar polygons.

[Visual Basic]

A Visual Basic application can help ensure that coplanar polygons are rendered properly by adding a bias to the z-values that the system uses when rendering the sets of coplanar polygons. To add a z-bias to a set of polygons, call the Direct3DDevice7.SetRenderState method just before rendering them, setting the first parameter to D3DRENDERSTATE_ZBIAS, and the second parameter to a value between 0-16 inclusive. A higher z-bias value will increase the likelihood that the polygons you render will be visible when displayed with other coplanar polygons.