compound alpha test

hi,
im trying to do compound billboarding per se…
i have a texture that i would like (for example) filtered so that only alpha values between .3 and .5 are rendered.
what i am trying to do is
glAlphaFunc(GL_GREATER,.3);
glAlphaFunc(GL_LESS,.5);
(and yes…im skipping a lot of syntax)
what i am noticing is that the second alphafunc (the gl_less) is overriding the gl_greater.

is there any way to do compound alpha masking?
thanks in advance
andrew

You can only set one alphatest condition. Have a look at http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/006293.html for a possible solution to your problem.

kon

Hi

I think with the GL_ARB_texture_env_combine extension you can do it. Use one texture unit to subtract your lower border (here 0.3) from the alpha value of your pixel. Set this lower border as the texture environments constant color alpha and let the texture units alpha (GL_COMBINE_ALPHA_ARB) do GL_SUBTRACT with GL_TEXTURE/GL_ALPHA_ARB and GL_CONSTANT_ARB/GL_ALPHA_ARB. Then set the alpha test to do GL_GREATER and the reference value to (upper border- lower border)
I haven’t tested it but it should work. Perhaps you can get problems with alpha values of <0.3 beeing rendered, but test it and you will see.

Bye
ScottManDeath

This is easy to do, if you have a stencil buffer. To draw an object that statisfies the alpha test min<a<max, first draw the object into the stencil buffer only using an alphatest of less than max. Then draw the object using an alphatest of greater than min, and a non zero stencil test.

[This message has been edited by DFrey (edited 08-22-2002).]

Originally posted by DFrey:
[b]This is easy to do, if you have a stencil buffer. To draw an object that statisfies the alpha test min<a<max, first draw the object into the stencil buffer only using an alphatest of less than max. Then draw the object using an alphatest of greater than min, and a non zero stencil test.

[This message has been edited by DFrey (edited 08-22-2002).][/b]

Hi

I thought also this could work but I think that alpha test is done after depth/stencil test.So all pixels pass the stencil/depth test and then they get alpha tested.So the combined testing won’t work.

I could be wrong, so I’m going to consult the blue book…

Bye
ScottManDeath

Hi

well DFrey you are right.The blue book says that alpha test is done before the stencil/depth test and you your approach will work fine

Bye
ScottManDeath

I have a short little demo with source code illustrating this method.
http://bellsouthpwp.net/d/f/dfrey69/DoubledSidedAlphaTest.zip

It requires GLUT and DevIL.

P.S. Yes, calling it DoubledSidedAlphaTest was a typo I made in the AppWizard but felt too lazy to deal with correcting after discovering the typo at the time of uploading the zip file. I meant to call it DoubleSidedAlphaTest.

Just wanted to note I have a tweaked version of the demo now at http://bellsouthpwp.net/d/f/dfrey69/DoubleSidedAlphaTest.zip .
All I did was correct most of the spelling errors in the source code, and tweak the animation and texture a bit to produce a funkier effect. The original demo from previous post is still there too.