GL_EXT_stencil_two_side & GL_ATI_seperate_stencil

Hi,

I am trying to implement shadow volume. To speed up the rendering I try to use GL_EXT_stencil_two_side & GL_ATI_seperate_stencil but unsuccessfully.

My two pass program is :

glEnable(GL_CULL_FACE);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 0, 1);

glStencilMask(1);

glStencilOp(GL_KEEP, GL_KEEP, GL_INCR_WRAP_EXT);
glCullFace(GL_BACK);
renderShadowVolume();

glStencilOp(GL_KEEP, GL_KEEP, GL_DECR_WRAP_EXT);
glCullFace(GL_FRONT);
renderShadowVolume();

////////////////////////////////////

My GL_EXT_stencil_two_side program is :

glEnable(GL_CULL_FACE);
glEnable(GL_STENCIL_TEST);
glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);

glActiveStencilFaceEXT(GL_FRONT);
glStencilMask(1);
glStencilFunc(GL_ALWAYS, 0, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_DECR_WRAP_EXT);

glActiveStencilFaceEXT(GL_BACK);
glStencilMask(1);
glStencilFunc(GL_ALWAYS, 0, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR_WRAP_EXT);

renderShadowVolume();

////////////////////////////////////

My GL_ATI_separate_stencil program is :

glEnable(GL_STENCIL_TEST);

glStencilMask(GL_TRUE);
glStencilFunc(GL_ALWAYS, 0, 1);

glStencilOpSeparateATI(GL_BACK, GL_KEEP, GL_KEEP, GL_INCR_WRAP_EXT);
glStencilOpSeparateATI(GL_FRONT, GL_KEEP, GL_KEEP, GL_DECR_WRAP_EXT);

renderShadowVolume();

////////////////////////////////////

Did you see something wrong ?
The 2 pass program works but the others don’t.
With GL_EXT_stencil_two_side I don’t anything about shadow volume and with GL_ATI_seperate_stencil, the shadow volume is fully draw…

My GL_ATI_separate_stencil code path pass now.
cull face was enable with was wrong.

At last, is there an ARB extension scheduled ?

My GL_ATI_separate_stencil code path pass now.
cull face was enable with was wrong.
what exactly was wrong? i’d like to use it as well :slight_smile: btw - will this extension only work on ati cards?

Originally posted by Groovounet:
At last, is there an ARB extension scheduled ?
AFAIK its in the core.

Originally posted by marco:
[quote]Originally posted by Groovounet:
At last, is there an ARB extension scheduled ?
AFAIK its in the core.
[/QUOTE]Yes, two sided stencil supportis in OpenGL 2.0 core.

I look you right :

I.5 Separate Stencil
Separate stencil functionality may be defined for the front and back faces of primitives,
improving performance of shadow volume and Constructive Solid Geometry
rendering algorithms.
Separate stencil was based on the the API of the ATI separate stencil
extension, with additional state defined by the similar EXT stencil two side
extension
Well well. So I need to use “glStencilOpSeparate” but what is the “additional state defined by the similar EXT stencil two side” ?

GL_STENCIL_TEST_TWO_SIDE_EXT ? In the glext.h there isn’t some like that in OpenGL Core declaration…

Also with extension do I have to check for make sute that this feature is available on the card ?

Would you please to tell me more information about ARB stencil separate ?

Originally posted by Groovounet:
Would you please to tell me more information about ARB stencil separate ?
There is no such extension. Take a look at the OpenGL 2.0 specification, section 4.1.5, page 202.

Thanks you. I have understand how it should work.

But under Windows, there isn’t a OpenGL 2.0 core implementation, so how to check if this feature is available ?

stencil_seperate = GL_ATI_stencil_seperate || GL_EXT_stencil_two_side;

No. Just check if OpenGL Version using glGetString(GL_VERSION). If OpenGL 2.0 is supported then you can call *GetProcAddress(“glStencilFuncSeperate”);
Or you use GLEW or something like that

But a GeForce5 could said : “I am OpenGL 2” with the last drivers but is false…

i used your code for ati’s seperate stencil extension to test it in a tutorial, but i get one of the most seen shadow volumes bug:

if z-fail is needed:

glStencilMask(GL_TRUE);
glStencilFunc(GL_ALWAYS, 0, ~0);
glStencilOpSeparateATI(GL_BACK, GL_KEEP, GL_INCR_WRAP_EXT, GL_KEEP);
glStencilOpSeparateATI(GL_FRONT, GL_KEEP, GL_DECR_WRAP_EXT, GL_KEEP);


if z-pass is ok:
glStencilMask(GL_TRUE);
glStencilFunc(GL_ALWAYS, 0, ~0);
glStencilOpSeparateATI(GL_BACK, GL_KEEP, GL_KEEP, GL_INCR_WRAP_EXT);
glStencilOpSeparateATI(GL_FRONT, GL_KEEP, GL_KEEP, GL_DECR_WRAP_EXT);