I have a picture of a tree in OpenGL as a 2D texture. I want to remove the background (skyblue) or rather make that part transparent. How can I do this in the fragment shader. The closest I came up with is removing the pixels of the texture that are above a threshold value. For e.g
#version 330
in vec2 texCoord;
out vec4 outColor;
uniform sampler2D theTexture;
void main()
{
vec4 texel = texture(theTexture, texCoord);
if(texel.b < threshold)
discard;
outColor = texel;
}