PDA

View Full Version : Writing directly to the stencil buffer



sleap
09-08-2013, 09: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?

mbentrup
09-09-2013, 01: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.

tksuoran
09-12-2013, 03:34 PM
http://www.opengl.org/registry/specs/ARB/shader_stencil_export.txt