PDA

View Full Version : multiple stencils ?



-Ekh-
03-10-2009, 03:45 AM
how far is it possible to have or simulate multiple stencil buffers ?

Y-tension
03-10-2009, 09:12 AM
...Not possible to have, there is one (hardware accelerated)stencil attachment to framebuffers. Simulate if you can write to a buffer and read simultaneously you can discard fragments based on buffer values. Not sure if this is allowed however.

-Ekh-
03-10-2009, 09:57 AM
What I want to do is to do some stencil stuff during a rendering and to combine the rendering with the stencil buffer with a second pass, so something like this:



void Render()
{
DoSomeStencilStuff();
Draw();
DoSomeStencilStuff2();
Draw();
}

void Draw()
{
DoSomeStencilStuff3();
DrawThings();
DoSomeStencilStuff4();
DrawThings2();
}


So, this is impossible ?

_NK47
03-10-2009, 10:37 AM
you can combine values with f.e. INCR/DECR for as long as possible (2^8 times) as long as you don't clear the stencil buffer.

dletozeun
03-10-2009, 01:33 PM
What I want to do is to do some stencil stuff during a rendering and to combine the rendering with the stencil buffer with a second pass


This is exactly the purpose of the stencil buffer, why would you want multiple stencil buffers attached to your framebuffer?

-Ekh-
03-10-2009, 02:03 PM
Well, I forgot to tell that I need to clear the stencil buffer between the 2 passes.

dletozeun
03-10-2009, 02:22 PM
There is no problem with that, you can do it, call glClear.

-Ekh-
03-11-2009, 05:16 AM
So, it's okay as long as I clear between the 2 passes. But if, for some reasons, I also need to clear between the 2 drawings (so clearing in between the 2 passes) there aren't any solution ?

Relic
03-11-2009, 05:50 AM
glClear gets a bitmask. You can choose to clear only color and/or depth and keep your stencil buffer intact as long as you want.

Y-tension
03-14-2009, 05:17 PM
also Check this out http://www.opengl.org/registry/specs/EXT/stencil_clear_tag.txt