I have just started switching a renderer I am using to draw some 3D shapes from EX9 to DX11. I am trying out Superphong and its looking really nice. I am using basically one of the examples that is using a Renderer(DX11 Temp Target) into a Preview(DX11.Texture) node.
But somehow the depth buffer is giving me headache. If I leave the depth buffer at the default D32_Float, then I get terrible artifacts wherever geometry is intersecting:
You are absolutely right. There is also a nice article on Wikipedia here with possible solutions.
Reducing the near plane and far plane distance solved it! It was set to 0.1 and 100.000 and I have reduced it to 10 and 10.000 now and the flickering is almost gone. I will add a small random amount of scaling and rotation to everything, to avoid coplanar faces.
the geometry does not look like it should be z-fighting… do you have some extreme distances or perspective settings?
z-fighting does only happen if the precision of the floating numbers is insufficient.
Yeah, kind of. The created geometry can be quite large or quite small. The camera can dolly in and out and generally things can be sort of between 0.1 and 10.000 units in size. The problem seems to have been the very large depth it was looking at (near plane 0.1, far plane 100.000). Now that I have lowered it to 100 and 10.000 there is no more flickering. I will now actually calculate the size of the visible geometry and adjust near and far plane on the fly, to get the least flickering.