alphatest greater 0.0 && less 0.5

basically im wanting to do an alphatest between a certain range, i know this aint possible to do with the standard alphatest, but does anyone have an idea of some trick i could use to get this done in one pass? (perhaps involving stencil)
ta

hmmm i just thought if i can add 0.5 to each fragment then i can do a single comparrison test! still that leaves me with the question of how to do that

Could you do it with ARB_texture_combine using GL_ADD and an extra texture. The texture could be a 1x1 texture with a value of 0.0,0.0,0.0,0.5f. You wouldn’t need any texture coords (or rather you could just use 0,0).

Of course the problem, which I realised as I submitted, is that your values are clamped from 0.0f to 1.0. So adding your 0.5 will cause everything above 0.5f to be included in your test…

If you have dependent reads (GF3 and up, I suppose) you can probably run the alpha as a texture coordinate into another texture, which contains alpha 1 or 0 for the input values as appropriate.

Set the alphatest to greater than the lower value and use combiners to only accept fragments which have an alpha value smaller than the upper value.

kon

If you’re using shaders it’s pretty easy to tweak the alpha before you write it out. If you want to kill everything out of for instance the range [0.2, 0.4], you’ll only have to do a alpha test for alpha == 1, and simply set alpha to 1 in the shader whenever it’s outside that range.