View Full Version : alphatest greater 0.0 && less 0.5

10-02-2004, 01:54 PM
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)

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

10-02-2004, 03:40 PM
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).

10-02-2004, 03:42 PM
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...

10-02-2004, 05:52 PM
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.

10-04-2004, 04:10 AM
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.


10-04-2004, 05:48 PM
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.