I want to make transparency on my 32bit bitmap texture using GLSL. My fragment shader looks like this:
#version 120
uniform sampler2D myTexture;
varying vec2 TexCoord;
void main(void)
{
if(texture2D(myTexture, TexCoord).a != 1.0f)
{
discard;
}
gl_FragColor = texture2D(myTexture, TexCoord);
}
But that makes transparent only the pixels where alpha is equal 0 and I want to maintain the fade from the texture. For example in this picture the first image is the texture, the second is the texture mask and the third is the desired result:
The texture and the texture mask are in one 32bit bitmap.
Does anyone know, how to achieve this using GLSL?