- Home /
Alpha 8 to save Texture size?
Hi!
I'm working on an app for android and iOS. Memory and texture sizes are a problem -- whenever the app goes into the background, it has to restart, because Android kills the process (it takes up too much memory), so I'm looking at alternate ways of storing the textures in memory. I came upon an idea.
I'm working with a texture that is 1024 x 238. At RGB24, it's 1.7mb. If I switch the compression to Alpha 8, it shrinks down to 446kb. Huge drop! It's ok, too, because the texture is only white and alpha. So technically, no data has really been lost. However, The white that was in the image is now black -- and I can't seem to figure out a way to tint it (back to white). So, two questions:
1) How do you tint a texture that is in alpha 8 format? Is this possible? I'm working with UITextures in NGUI, if that helps. 2) Is this really going to save on the texture's size in memory?
Cheers,
Simon
Answer by gstock · Jul 02, 2014 at 06:59 AM
Verify that the "Alpha is Transparency" setting is set on the texture file on the inspector. Also, you should check that the material that your object uses has a shader that supports transparency.
Thanks for your answer...but Alpha is Transparency doesn't seem to affect it...
Answer by Japa · Jun 30, 2015 at 12:55 PM
Alpha8 means that is only stores alpha, nothing else. This means that the white of the main texture is lost.
The only way I would use an Alpha8 texture (And I plan to, actually) is from a shader set to specifically use it.
If you write a custom shader that just uses a color and the alpha map from a texture, then you can use an Alpha8 texture.
Answer by spalmer · Jun 30, 2015 at 04:32 PM
Unity needs grayscale image compression format options. Alpha8 isn't quite a drop-in replacement for the functionality we need. If you select the Alpha from grayscale option it will get you partway there, then you must take the shader you would have used and change it to read its color from the alpha channel instead of rgb. It's probably more trouble than it's worth.
Answer by Earlybird · Mar 11, 2017 at 08:14 AM
You need a shader that uses the alpha 8 texture for alpha only and tint the albedo with _color only.
So the output would be something like this
O.albedo = _color.rgb;
O.alpha = _Maintex.a;
Your answer
Follow this Question
Related Questions
How to find what texture compression was forced for build? 1 Answer
Default Texture Platform/Format settings 2 Answers
Failed to generate ETC texture UnityEditor.HostView:OnGUI()...Why? 0 Answers
garbage collection not cleaning up material that isn't referenced on android 1 Answer
Low Memory Crash on iPad1 1 Answer