PDA

View Full Version : GL_EXT_stencil_two_side & GL_ATI_seperate_stencil



Groovounet
11-08-2005, 01:32 AM
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...

Groovounet
11-08-2005, 01:47 AM
My GL_ATI_separate_stencil code path pass now.
cull face was enable with was wrong.

Groovounet
11-08-2005, 02:10 AM
At last, is there an ARB extension scheduled ?

Vexator
11-08-2005, 02:32 AM
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 :) btw - will this extension only work on ati cards?

marco_dup1
11-08-2005, 03:05 AM
Originally posted by Groovounet:
At last, is there an ARB extension scheduled ?AFAIK its in the core.

Corrail
11-08-2005, 06:21 AM
Originally posted by marco:

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

Groovounet
11-08-2005, 08:39 AM
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 ?

Corrail
11-08-2005, 09:30 AM
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.

Groovounet
11-09-2005, 01:37 AM
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;

Corrail
11-09-2005, 01:59 AM
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

Groovounet
11-10-2005, 12:15 AM
But a GeForce5 could said : "I am OpenGL 2" with the last drivers but is false...

Vexator
11-11-2005, 09:26 AM
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:

http://www.vexator-battlefield.de/argh.jpg

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);