View Full Version : Writing directly to the stencil buffer

09-08-2013, 08:28 PM
Instead of the standard increment, replace etc operations on the stencil buffer I'd like to be able to write arbitrary values directly from a shader. I don't mind of this is during typical rendering with the stencil buffer bound via a frame buffer or the image_load_store extension or anything else. I just want to assign varying values in a single pass. I'm not aware of a way to do this, does anyone here have any ideas?

09-09-2013, 12:48 AM
Unless you have a driver supporting GL_ARB_shader_stencil_export there's no easy way to do that. When I needed a certain pattern in the stencil buffer for stencil routing I ended up with an 8-pass implementation that wrote one stencil bit per pass using the standard stencil ops.

09-12-2013, 02:34 PM