VengefulPastry
01-04-2005, 02:38 PM
For my latest DirectX non-trick:
I am having trouble with the stencil buffer not playing well with the z-buffer.
The stencil buffer works by not writing any pixel value of zero (black) onto the scene. The z-buffer works by not writing any pixel that is farther away from the camera than the pixel in front of it.
Here is the problem: when writing a texture to the scene, it seems all of the black pixels (total value zero) are nonetheless being given a depth value. So, if it just so happens this texture is closer to the camera than the next texture, all of those black pixels are being written to the final scene, because although they are black, they are closer to the camera....
Has anybody else experienced this, and did you come up with a solution? Bumbling through the MicroSoft archives, I have found you can alter behavior if the stencil passes but the depth fails, but I can't find out if there is something I can do if the stencil fails but the depth passes (which seems to be the case, here).
Thanks!
I am having trouble with the stencil buffer not playing well with the z-buffer.
The stencil buffer works by not writing any pixel value of zero (black) onto the scene. The z-buffer works by not writing any pixel that is farther away from the camera than the pixel in front of it.
Here is the problem: when writing a texture to the scene, it seems all of the black pixels (total value zero) are nonetheless being given a depth value. So, if it just so happens this texture is closer to the camera than the next texture, all of those black pixels are being written to the final scene, because although they are black, they are closer to the camera....
Has anybody else experienced this, and did you come up with a solution? Bumbling through the MicroSoft archives, I have found you can alter behavior if the stencil passes but the depth fails, but I can't find out if there is something I can do if the stencil fails but the depth passes (which seems to be the case, here).
Thanks!