0
votes

I am using this fragment shader:

#version 150 core

uniform sampler2D texture1;

in vec4 pass_Color;
in vec2 pass_TextureCoord;

out vec4 out_Color;

void main(void) {
    out_Color = pass_Color;
    // Override out_Color with our texture pixel
    out_Color = texture(texture1, pass_TextureCoord) * pass_Color  ;
}

Now to pass_Color i give an rgba value. I change up the alpha value. the texture is rgba aswell, its a PNG file. I use blending mode GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA.

Now the problem is that the alpha value that I pass in doesn't affect anything..

and I want it to..

1
What exactly are you wanting it to affect (it almost looks like you expect blending to occur within your fragment shader by setting out_Color twice...)? It's really the value of texture (texture1, pass_TextureCoord).a * pass_Color.a that you are interested in, by the way (that is the value used for blending, not pass_Color.a).Andon M. Coleman
What do you mean? the .a on the texture() call doesnt compileAmit Assaraf
What I meant was that only the alpha component affects blending. And you are multiplying the alpha component of the texture by the alpha component of pass_Color.a. It is the result of multiplying the two that determines how your fragment is blended.Andon M. Coleman

1 Answers

0
votes

I ended up doing this:

vec4 tex =  texture(texture1, pass_TextureCoord);
out_Color = vec4(tex.r*(pass_Color[0]),tex.g*(pass_Color[1]),tex.b*(pass_Color[2]),tex.a*(pass_Color[3])) ;

Works just fine!