float TestPackUnsignedNormalizedFloat4ToFloat(float* aValues)
{
assert( aValues[0] <= 1.0f && aValues[1] <= 1.0f && aValues[2] <= 1.0f && aValues[3] <= 1.0f &&
aValues[0] >= 0.0f && aValues[1] >= 0.0f && aValues[2] >= 0.0f && aValues[3] >= 0.0f);
unsigned long packedColor = (UNFloatConvertChar(aValues[0]) << 24) | (UNFloatConvertChar(aValues[1]) << 16) | (UNFloatConvertChar(aValues[2]) << 8) | UNFloatConvertChar(aValues[3]);
float packedFloat = (float) ( ((double)packedColor) / ((double) (0xFFFFFFFF)) );
return packedFloat;
}
//Helper method to emulate GLSL
float frac(float value)
{
return (float)fmod(value, 1.0f);
}
//UnPack 3 values from 1 float
CVec4 UnPackUnsignedFloat(float src)
{
return CVec4( frac(src),
frac(src * 256.0f),
frac(src * 65536.0f),
frac(src * 16777216.0f) );
}