How to deal with etc1 alpha channel

406 views Asked by At

I'm trying to support ETC1 for my android game but I have no idea how to deal with the alpha channel.

Can anyone tell me where to start and how to get ETC1 working with alpha?

Update: Using: gl_fragColor = vec4(tex1.rgb,tex2.a);

doesn't work, there is still a black rectangle around my texture

1

There are 1 answers

1
MichaelCMS On

You need to do an alphamask shader.

Basically instead of having 1 texture for full color information including the transparency, have 1 texture for rgb (etc1) and 1 texture for alpha (can also be etc1).

Then in your fragment shader, assign rgb from the first texture and alpha from the 2nd.

 gl_fragColor = vec4(tex1.rgb,tex2.a);

!Note the code above is just for exeplifying the approach, the syntax might be wrong.