Hi,
I’m wanting to implement a stencil routed A-buffer in OpenGL, as in this paper :
http://www.sci.utah.edu/~bavoil/research/kbuffer/StencilRoutedABuffer_Sigg07.pdf
Does anyone have any code to post ?
Or can anyone give me some pointers on how to set up the stencil test ? The first thing I would do is set up a multisample FBO with, for example, a 4 sample color render buffer, and a 4 sample depth-stencil render buffer. How then do I set up the stencil test ?
// do I have to bind the framebuffer, and a particular render buffer (color / depth-stencil) here first ?
glEnable(GL_SAMPLE_MASK_NV);
GLbitfield M = 1;
for (unsigned int si=0; si<num_samples; ++si)
{
glSampleMaskIndexedNV(si, M);
M = M << 1;
}
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_EQUAL, 0x01, 0xFF);
glStencilOp(GL_DECR, GL_DECR, GL_DECR);
// rendering ...
// before rendering to the FBO do I glClearStencil(), and with what ?
glDisable(GL_MULTISAMPLE)
glDisable(GL_DEPTH_TEST) // don't need it (but can't create a stencil-only render buffer)
glEnable(GL_STENCIL_TEST)
// set up fragment shader (Cg .. using samplerRBUF ..)
// use glTexRenderbufferNV(GL_TEXTURE_RENDERBUFFER_NV, ...) to let the shader access the render buffer
// etc
// Render to FBO
Any help would be much appreciated.