Sign in to follow this  
Viik

Float to ARGB using mantissa and exponent

Recommended Posts

I'm trying to pack a float value [0..1] into ARGB texture. The problem is that values are sparsely distibuted over 0..1 range and this kind of pack\unpack: HLSL (Pixel Shader): Pack 32-bit float to 32-bit A8R8G8B8 render target dosn't provide enought precision. Its a bit strange to me, because 32 bit float has 23bit for storing mantissa, the values are in 0..1 range so packing them into ARG8bit gives at least the same precision. Unless float stores mantissa starting from first non zero value, so 0.00345 would have mantissa of 3.45 or 345, not sure if that's a case. Anyway, I'm trying to pack it using different way - using frexp() and separately coding mantissa and exponent. Right now I'm heaving difficulties with it as don't understand how these numbers look a like. For example, I'm passing extracted exponent to the sceen and when float value is less than one, exponent is always zero, if its bigger than one than exponent is bigger then one. With mantissa even more crazy stuff is happening. Can somebody explaine how does extracted mantissa and exponent look a like?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this