Skip to content

Instantly share code, notes, and snippets.

@benoitjacquier
Created November 15, 2013 10:26
Show Gist options
  • Save benoitjacquier/7482254 to your computer and use it in GitHub Desktop.
Save benoitjacquier/7482254 to your computer and use it in GitHub Desktop.
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