I haven't test it in deep but I'll do it while implementing my next game.

I attached the files I changed to make it work. I'm using version 1.4.1.

I'm still having an issue because I'm packing 4 bytes (RGBA) into a single float but because I didn't find a better way I'm actually using just 6 bits for each component.

This restrict the range of available colors but in my case it's not a big issue.

Anyway if anyone know a better way to pack 4 bytes into a float without lose too much precision please give me a tip!

Here's what I'm using to pack and unpack RGBA:

- Code: Select all
`static float PRECISION = 64.0f;`

public static float colorToFloat(Color color) {

float value = 0;

value += Math.floor(color.r * (PRECISION - 1)) * PRECISION * PRECISION * PRECISION;

value += Math.floor(color.g * (PRECISION - 1)) * PRECISION * PRECISION;

value += Math.floor(color.b * (PRECISION - 1)) * PRECISION;

value += Math.floor(color.a * (PRECISION - 1));

return value;

}

public static Color floatToColor(float v) {

float value = v;

Color color = new Color();

color.a = (value % PRECISION) / (PRECISION - 1);

value = (float) Math.floor(value / PRECISION);

color.b = (value % PRECISION) / (PRECISION - 1);

value = (float) Math.floor(value / PRECISION);

color.g = (value % PRECISION) / (PRECISION - 1);

value = (float) Math.floor(value / PRECISION);

color.r = value / (PRECISION - 1);

return color;

}

In theory I should be able to pack 3 bytes into significand and the remaining one into the exponent but I don't really know how to do it.