I'm facing an issue with a fragment shader where I have a texture being passed to it and I want to overlay a color with 50% alpha on top of it. While I've managed to partially achieve this, the original texture seems to lose its alpha channel.
Here's my current setup:
uniform sampler2D texture;
varying vec2 vUv;
void main() {
vec4 tColor = texture2D(texture, vUv);
vec4 color = vec4(1.0, 0.0, 0.0, 0.5);
gl_FragColor = vec4(mix(tColor.rgb, color.rgb, color.a), 1.0);
}
Upon closer inspection, it's evident that the alpha channel of the texture is not being considered in gl_FragColor
. I'm currently at a loss on how to incorporate it correctly.