I am currently trying to use the stencil buffer in my deferred renderer (DX, Windows)
I am careful with changing rendertargets, so the depth buffer is correctly available at every stage in the renderer - unfortunately the stencil buffer is not?
I want to use the stencil for outlining and so I do set the stencil buffer in an early pass (it is getting set and populated, I checked that) and want to use the stencil information later on in a forward pass. But the stencil is all 0.
A first idea would be, that the rendertarget switching did somehow clear or resolve the stencil buffer - but the depth buffer is still as it should be and I can use it at the same spot, just the stencil was cleared? How is that possible, as I assumed depth/stencil use the same memory/buffer?
Anyone has a hint, what can cause the stencil to be cleared but the depth not? (I do not clear it manualy)