Search code examples
directxdirectx-10

Why my pixels are not clipped against near/far planes


I have a really weird problem. I render some triangles in the scene with D3D10 and what is surprising is that color values of these pixels are not clipped against near/far planes. On the other hand, depth values seem to be clipped fine. Evidence that this works as I have just described is as following:

  • when I render objects in the z-range that is "within" view frustum, everything is fine
  • when one object is inside the z-range and one is in front of it (between camera's eye and near plane), the objects inside the z-range "shines thhrough" the object that is closer. So z-buffering is working perfectly fine
  • I also checked output VS vertices values; all vertices that are outside the z-range and should be clipped (and they are in the z-buffer but are not in the color buffer) have their Z/W values outside [0, 1] interval

Idea idea what could be wrong? I think it might be some render state set incorrectly but I don't really know where to look.


Solution

  • I'm making your comment an answer, as it was exactly the issue I had in D3D11 (same in D3D10).

    Make sure that you set DepthClipEnable to TRUE in any D3D11_RASTERIZER_DESC in question.