Created
November 15, 2013 10:26
-
-
Save benoitjacquier/7482254 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float encode16bits(float2 xy16) | |
{ | |
xy16 = floor( xy16/16 ); | |
float packed = xy16.x*16 + xy16.y; | |
packed /= 255.0f; | |
return packed; | |
} | |
float2 decode8bits(float packed) | |
{ | |
packed *= 255.0f; | |
float2 xy; | |
xy.x = floor(packed / 16 ); | |
xy.y = fmod(packed,16); | |
xy *= 16; | |
xy /= 255.0f; | |
return xy; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment