frostbite
05-21-2008, 01:01 PM
Hi.
I'm interested in what happens to the alpha test reference value and an alpha value from texture when they have to be compared. For example, if texture format has 8 bit alpha (integer) and I provide some alpha function and reference value (as float), then somewhere there must be either float->integer conversion or vice versa to actually compare them. glAlphaFunc documentation unfortunately doesn't cover this in detail.
If I want to test for e.g. equality to a certain integer alpha value, is there a general and reliable way to do so? I mean something like glAlphaFunc(GL_EQUAL, intval / 255.0f). Only that sometimes suffers from what I think is float<->int conversion precision issues in compiler or driver (it doesn't always work as expected). In the particular case where this didn't work, that involved GL_GEQUAL, adding a very small value (like 0.000001) after dividing by 255 did help. But I'm looking for some general and portable way of solving the problem, if any exist.
I appreciate any help. Thanks.
I'm interested in what happens to the alpha test reference value and an alpha value from texture when they have to be compared. For example, if texture format has 8 bit alpha (integer) and I provide some alpha function and reference value (as float), then somewhere there must be either float->integer conversion or vice versa to actually compare them. glAlphaFunc documentation unfortunately doesn't cover this in detail.
If I want to test for e.g. equality to a certain integer alpha value, is there a general and reliable way to do so? I mean something like glAlphaFunc(GL_EQUAL, intval / 255.0f). Only that sometimes suffers from what I think is float<->int conversion precision issues in compiler or driver (it doesn't always work as expected). In the particular case where this didn't work, that involved GL_GEQUAL, adding a very small value (like 0.000001) after dividing by 255 did help. But I'm looking for some general and portable way of solving the problem, if any exist.
I appreciate any help. Thanks.