XNA 4 RenderTarget Stencil Buffer

Started by
0 comments, last by phil_t 9 years, 7 months ago

Hi.

Can somebody explain to me or point me to a resource on using a basic stencil buffer on a render target in XNA 4? I'm finding a lot of XNA 3 resources and I know that it's changed in XNA 4, and a lot of articles on XNA4 that are overkill and confusing.

I want a rendertarget with a stencil buffer, which is drawn to during initialization. Then at draw time I want to pass the render target to the pixel shader, selecting pixels from the passed render target to render to the current render target, but discarding pixels based on the original render target's stencil buffer.

I THINK, correct me if I'm wrong:

The graphics device has a stencil buffer which is zeroed out when you set the rendertarget.

I have to enable the stencil buffer.

I can set the game state to compare the graphics device stencil buffer and the render target stencil buffer at draw time.

BUT, how do I set the values in the render target stencil buffer?

Also I'm using Multiple Render Targets, if this makes any difference.

I know this is probably simple stuff but I'm not finding any resource that gives a simple explanation of What It Is and How To Use It.

Thanks

Advertisement

In XNA 4.0 the stencil buffer (and depth buffer) are tied to the particular render target - you specify it when you create the render target. So you can't set a new render target and use the stencil buffer from a previous one.

What exactly are you trying to do?

This topic is closed to new replies.

Advertisement