diff --git a/src/image.cpp b/src/image.cpp index b38637d7..6f8f7977 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -1122,29 +1122,38 @@ namespace bgfx // https://www.opengl.org/registry/specs/EXT/texture_shared_exponent.txt const int32_t expMax = (1<>23) & 0xff) - 127) ) ) + 1 + expBias; + float denom = bx::fpow(2.0f, float(expShared - expBias - MantissaBits) ); - _dst[0] = rr * invExp; - _dst[1] = gg * invExp; - _dst[2] = bb * invExp; - _dst[3] = expShared; + if ( (1< void decodeRgbE(float* _dst, const float* _src) { const int32_t expBias = (1<<(ExpBits - 1) ) - 1; - const float exp = bx::fpow(2.0f, _src[3]-float(expBias-MantissaBits) ); - _dst[0] = _src[0] * exp; - _dst[1] = _src[1] * exp; - _dst[2] = _src[2] * exp; + const float exponent = _src[3]-float(expBias-MantissaBits); + const float scale = bx::fpow(2.0f, exponent); + _dst[0] = _src[0] * scale; + _dst[1] = _src[1] * scale; + _dst[2] = _src[2] * scale; } // RGB9E5F @@ -1154,10 +1163,10 @@ namespace bgfx encodeRgbE<9, 5>(tmp, _src); *( (uint32_t*)_dst) = 0 - | (toUnorm(tmp[0], 511.0f) ) - | (toUnorm(tmp[1], 511.0f)<< 9) - | (toUnorm(tmp[2], 511.0f)<<18) - | (uint32_t(tmp[3]) <<27) + | (uint32_t(tmp[0]) ) + | (uint32_t(tmp[1]) << 9) + | (uint32_t(tmp[2]) <<18) + | (uint32_t(tmp[3]) <<27) ; }