Depth Bias

To solve Z fighting issue: use depth bias.
An 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 IDirect3DDevice9::SetRenderState method just before rendering them, setting the State parameter to D3DRS_DEPTHBIAS, and the Value parameter to a value between 0-16 inclusive. A higher z-bias value increases the likelihood that the polygons you render will be visible when displayed with other coplanar polygons.
where m is the maximum depth slope of the triangle being rendered.
m = max(abs(delta z / delta x), abs(delta z / delta y))  

                                              Z Slope Scale = 0.0, Depth Bias = 0.0

                                             Z Slope Scale = 0.1, Depth Bias = 0.0

                                            Z Slope Scale = -0.2, Depth Bias = 0.0

                                          Z Slope Scale = -0.0, Depth Bias = -0.01

                                          Z Slope Scale = -0.0, Depth Bias = 0.01

Program demo:


Post a Comment

Popular posts from this blog


After reading Steve Jobs Autobiography

Drawing textured cube with Vulkan on Android