Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android/opengles alpha textures not semitransparent but binary transparent

I am drawing some textures with alpha channel, but when they are displayed it looks like the alpha channel is only binary. So a pixel is either transparent or opaque, although in the texture file itself the pixel is half-transparent. The blending is set up like this:

gl.glEnable(GL10.GL_BLEND);
gl.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);

Is there a workaround for this problem?

The above shows how it should be like, and the below shows how it is:

alt text

like image 206
clamp Avatar asked Sep 03 '10 09:09

clamp


2 Answers

Try this:

gl.glEnable(GL10.GL_BLEND);    
gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

gl.glEnable(GL10.GL_ALPHA_BITS);
//draw...
gl.glDisable(GL10.GL_ALPHA_BITS);
like image 54
cement Avatar answered Sep 18 '22 01:09

cement


It seems like it's using alpha testing instead of alpha blending, which would explain the thresholding behaviour. Although it isn't enabled by default, it might be worth to try:

gl.glDisable(GL10.GL_ALPHA_TEST);
like image 31
Aert Avatar answered Sep 21 '22 01:09

Aert