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).


1 Answer 1


I assume you are interested in the alpha channel for the purpose of alpha blending. Off the top of my head, I can think of one solution to this problem, but it is not going to perform well.

The fundamental problem here is that you have an RGB texture; it has a constant alpha of 1.0. You can use texture combiners to pre-multiply your RGB texture (Texture0) by the other texture with alpha encoded into RGB (Texture1), but that only solves half of your problem.

Texture0 = RGB
Texture1 = aaa

Texture Combiner:  Texture0.rgb * Texture1.rgb  =  RaGaBa

Traditional alpha-blending (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA):

 DstColor  =  SrcColor * SrcColor.a   +   DstColor * (1.0 - SrcColor.a)

Pre-multiplied alpha-blending (GL_ONE, GL_ONE_MINUS_SRC_ALPHA):

 DstColor  =  SrcColor * 1.0          +   DstColor * (1.0 - SrcColor.a)

You eliminated the need for an alpha channel in the first half of the blend function, but it still remains in the second half.

You can do this, though I would not recommend it:

 1.  Perform one pass applying Texture1
 1.1 Blend Function:  GL_ZERO, GL_ONE_MINUS_SRC_COLOR

     *** Framebuffer:   DstColor * (1.0 - SrcColor.a)

 2.  Perform a second pass applying the combined Texture0*Texture1
 2.1 Blend Function:  GL_ONE,  GL_ONE

     *** Framebuffer:   SrcColor * SrcColor.a   +   DstColor * (1.0 - SrcColor.a)

This will produce the desired end result, but it eats a lot of memory bandwidth... the very thing you were trying to conserve by using ETC1 texture compression in the first place. Honestly, the only performance-friendly solution is probably going to be to use ES 2.0 and shaders.

  • \$\begingroup\$ thanks @Andon M. Coleman I thought that this would be the inevitable conclusion of this little exercise :( Anyway, in the interim what I am doing is just using PKMs for backgrounds and such that don't care about alphas. I am then also just cleaning up my PNG sprites to conserve as much unnecessary space as possible and making one or two other tweaks. I think that that will make enough of a difference for now and should hold me out until I have time to look into OpenGL ES 2. \$\endgroup\$
    – brent777
    Commented May 25, 2014 at 23:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .