Jump to content
  • Advertisement
Sign in to follow this  
Viik

Float to ARGB using mantissa and exponent

This topic is 3283 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!