Render fragments with uvs outside (0,1) range as transparent I'm rendering an image onto a mesh. And I need to render fragments with uv coordinates that fall outside (0,1) range with full transparency. In the code below I'm specifying a border color with zero alpha. However I'm getting fully opaque border. That is when texture itself does not have alpha channel. Is it possible to use a texture without alpha channel but still render fragments outside of the range as transparent?
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
float border[] = {1, 1, 1, 0};
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, border);

Here is the fragment shader code:
out vec4 color;
in vec2 uv;
uniform sampler2D tex;

void main() {
    color = texture(tex, uv);
}

I enabled alpha blending like this:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Assuming that alpha works properly in the rest of the code it can be solved on shader level:
out vec4 color;
in vec2 uv;
uniform sampler2D tex;

void main() {
    color = texture(tex, uv);
    color.a = 0.0;
    if (all(greaterThan(uv, vec2(0.0))) &amp;&amp; all(lessThan(uv, vec2(1.0)))) {
        color.a = 1.0;
    }
}