- Home /
Black and White compression settings?
Hi there!
I'm making a entirely-black-and-white game which I think could save a lot of memory and GPU power if I would have been able to compress my textures to a format that doesn't have RGB. Preferably I would be looking for a compression that needs 2 bits for the black-to-white color (I think this is called Luminance) and 2 bits for alpha... or something like that?
Does anyone know how to do this, or hack this with the current options?
Answer by Bunny83 · Nov 10, 2015 at 11:28 AM
Well, the smallest native fromat that can directly be used is ARGB4444 and RGBA4444. It only has 16 bits per pixel. On IOS there's also the PVRTC_RGBA2 format which only has 2 bits per channel and requires 8 bit per pixel.
However if you only need truely black and white and only transparent or opaque you would need only 1 bit per channel and only a grayscale image. So you would have 2 bits per pixel. As far as i know there's no native format that would support this, The smallest adressable unit in a PC is a byte which consists of 8 bits. So you would need to "pack" 4 pixels into a single byte. That means your texture resolution has to be a multiple of 4, otherwise you would have left over pixels. It is possible to store an image in a 2bit per pixel format, but you have to "unpack" it at runtime so the GPU can work with it.
Also you won't save GPU power since the GPU always works with float values. That's what it's optimised for. So it would only save a bit of HDD memory. At runtime in RAM you would need at least 16 bit per pixel if you want alpha as well.
It could be reduced to 8 bit per pixel by encoding the alpha and the B&W bit into a single value. However you would need a special shader to unpack that inside the shader. This would have a problem: You can't use any of the standard shaders since you have to handle your custom format yourself.
Thanks for the answer! Somewhat disappointing that there's currently no solution for me. I guess I'll have to do with RGBA textures then...
Answer by Jessespike · Nov 10, 2015 at 11:16 AM
Try the Grayscale Image Effect: http://docs.unity3d.com/356/Documentation/Components/script-GrayscaleEffect.html, or use desaturated textures.
I'm not sure if it's possible todo what you're asking. Even if you were to use a custom texture, it probably wouldn't save a lot memory or GPU power as you think.
Thanks for your answer! However, I'm not looking for a way to make my game black and white - it already is! I'm simply looking for a way to compress the textures so that the size of the texture won't me as big in GPU memory as a RGBA texture. $$anonymous$$aybe I am asking too much indeed...