I'm trying to make sense of adjusting texture colors with a fragment shader. My fragment shader is super simple:
uniform sampler2D sampler;
void main() {
vec4 tex = texture2D ( sampler, uvVarying );
gl_FragColor = vec4(tex.r, tex.g, tex.b, tex.a);
}
This draws my dog texture as expected:
if I then change the shader to
gl_FragColor = vec4(tex.r, tex.g, tex.b, 1.0);
the result is what I expected, transparency info is lost:
but if I instead set it to:
gl_FragColor = vec4(tex.r, tex.g, tex.b, 0.0);
I was expecting it to disappear completely, but instead I get:
What is going on??
And to my original problem: I wanted to add a little red tint to my texture with:
gl_FragColor = vec4(tex.r + 0.5, tex.g, tex.b, tex.a);
Now, I was expecting it to have same transparency info as the original texture, but instead I get this:
What am I missing here. The texture is using default blending of the engine which is src = GL_ONE, dst = GL_ONE_MINUS_SRC_ALPHA
.