Alpha test reference value

hi all:
the ref parameter of glAlphaFuncx is fixed point, but when alpha compare
the alpha value from color is 8 bits, so the ref nust convert from fixed point to 8 bit, so must mapping [0…1] to [0… ff]

how to do this convert?

for example: fixed point 3300 convert to 8 bits value = 50 or 51??

The spec says that the fixed point value is converted to “an internal floating point format” by dividing the integer representing the 16.16 fixed point value by 2^16. However, it doesn’t say anything about the precision of that division or of the “internal floating point format” (which doesn’t really have to be floating point at all).

An accurate conversion is to take the clamped fixed point value, multiply it by 255, then round to nearest integer. Though you can save a bit of work by truncating the fractional part instead of rounding.

0000.3300h (= 0.19921875) * FFh = 0032.CD00h (= 50.80078125)
round -> 33h (51)
truncate -> 32h (50)

Both are acceptable.

hi Xmas:
thanks for your reply,
which one is the powerVR’s solution?
truncate or rounding?

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.