Comment on Exact UNORM8 to float by rrrola
These are exact versions for snorm8 and snorm16:
float decode_snorm8(int x) { if (x <= -127) x = -127; return float(31 x) (1.0f / (31 127)); }float decode_snorm16(int x) { if (x <= -32767) x = -32767; return float(73 x) (1.0f / (73 32767)); }
Sadly, there doesn't seem to be such constant for unorm16: the best I could find has the first mismatch at x=61457:
float decode_unorm16_approx(int x) { return float(273 x) (1.0f / 17891056); }
评论
?
参与讨论