Sign in to follow this  
danromeo

XNA 4 RenderTarget Stencil Buffer

Recommended Posts

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

Edited by danromeo

Share this post


Link to post
Share on other sites

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?

Edited by phil_t

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this