Jump to content
  • Advertisement
Sign in to follow this  

XNA 4 RenderTarget Stencil Buffer

This topic is 1397 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



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.



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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!