Sign in to follow this  
browny

how to access stencil buffer from shaders

Recommended Posts

I'm pretty confident that you can't access it directly. You could, however, do some sort of multipass thing where you do the following:

1. Write to stencil buffer

2. Switch to a render texture (with same dimensions and stencil buffer as the main render target)
3. Render all stencilled pixels in white (no depth writes or compares)
4. Render non-stencilled pixels in black (again, no depth writes or compares)

5. Switch back to main render target.
6. Use that texture from the shader. Then, white is "stenciled" and black is "not".

It's not as fast as direct access, but it's about the only thing I can think of to do if you actually NEED that data for something.

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