Search code examples
androidopengl-esopengl-es-1.1multitexturing

Is there a way to use the RGB channels of a texture as the alpha channel when applying multitexturing using OpenGL ES 1.1?


I have been trying to get texture compression using ETC1 (specifically PKM files) working for some time now. I am trying to do this without having to upgrade to OpenGL ES 2 so I have been using multi-texturing.

I have the multi-texturing working now (finally) but the problem is that it is not behaving as one would expect and I think that I have figured out why. When creating the PKMs you end up with PKM with the color components only and one with the alpha component only. Problem is that the alpha PKM seems to be storing the alpha value in the RGB channels. Black seems to represent full transparency and white seems to represent full opaqueness.

My question is: Is there a way to combine and convert these RGB values into an alpha value when using multi-texturing? If not, then I don't see any options for using ETC1 and supporting alphas under OpenGL ES 1.1 (please correct me if I am wrong).


Solution

  • I posted this question in different forums as well and the general consensus is that this is not possible. So if you want to implement ETC1 compression that handles alphas, then upgrade to OpenGL ES 2 first and use FragmentShaders.

    I decided not to do this. What worked really well for me was to just use ETC1 compression for my images where the alpha channel did not matter. For my other images where it did matter, I used quantization to dramatically decrease the size of my PNGs. You can do this using tinypng.org or you can install pngquant locally. I did the latter and wrote a bash script that uses ETC1 compression for certain images and pngquant for others and copies them to my assets directory - so its all done for me by just running a single script.