0
\$\begingroup\$

I'm using the cocos2d-x engine and want to support etc1 on android devices for my game. For ETC1 i'm using the mali compression tool, and GLSL.

Everything is working, but I can't change the opacity of my sprites anymore.

my alpha blending is GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA . can anyone help?

Here are one of my Textures with rgb tex + alpha tex

enter image description here enter image description here

Vertex Shader:

attribute vec4 a_position;
attribute vec2 a_texCoord;
attribute vec4 a_color;


varying vec4 v_fragmentColor;
varying vec2 v_texCoord;
varying vec2 v_texCoord2;


uniform sampler2D tex1;

void main()
{
    gl_Position = CC_PMatrix * a_position; //CC_PMatrix comes from engine
    v_fragmentColor = a_color;
    v_texCoord = a_texCoord;
    v_texCoord2 = v_texCoord;
}

Fragment Shader:

varying vec4 v_fragmentColor;   
varying vec2 v_texCoord;
varying vec2 v_texCoord2;

uniform sampler2D u_texture1; //alpha texture


void main()
{
    //CC_Texture0 comes from cocos2d-x engine and represents the rgb
    vec3 tex = texture2D(CC_Texture0, v_texCoord).rgb; 
    float alpha = texture2D(u_texture1, v_texCoord).r;

    gl_FragColor = vec4(tex,alpha);
}
\$\endgroup\$
  • \$\begingroup\$ From the Wikipedia description of ETC1: "It does not support the compression of images with Alpha components, although there are work-arounds for this." Are you using one of these techniques to work around this limitation? If so, which one? \$\endgroup\$ – DMGregory Jul 14 '15 at 14:40
  • \$\begingroup\$ Yes. I'm using Methode 2 \$\endgroup\$ – jeromintus Jul 14 '15 at 14:43
  • \$\begingroup\$ Can you show us a screengrab, your source textures (RGB & alpha), and the shader code you're using to render them? \$\endgroup\$ – DMGregory Jul 14 '15 at 14:50
  • \$\begingroup\$ updated my post above \$\endgroup\$ – jeromintus Jul 15 '15 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.