Reputation: 1003
I would expect my texture to disappear completely with the following fragment shader:
varying mediump vec2 text_coord_out;
uniform sampler2D sampler;
void main()
{
gl_FragColor = texture2D(sampler, text_coord_out);
gl_FragColor.w *= 0.0;
}
. . .it doesn't. I've also tried gl_FragColor.a. Thoughts?
Upvotes: 3
Views: 7234
Reputation: 3018
gl_FragColor.w = 0;
should work. Probably *= operation bewilders GLSL compiler.
Upvotes: 0
Reputation: 4194
Use gl_fragColor =
only once
vec4
in this case vec4 red = vec4( 1,0,0,1 );
gl_fragColor = red;
Upvotes: 7
Reputation: 1003
OMG...I totally fixed this. Fragment shader looks like this:
varying mediump float text_alpha_out;
varying mediump vec2 text_coord_out;
uniform sampler2D sampler;
void main()
{
gl_FragColor = texture2D(sampler, text_coord_out);
gl_FragColor = gl_FragColor * text_alpha_out;
}
and my blending looks like this:
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
Upvotes: 9
Reputation: 473174
Why should it disappear? The alpha value of the output color has no meaning unless you give it a meaning. Typically, that means using some form of blending. Note that the link describes desktop OpenGL; the GL ES equivalent works much the same way, but desktop GL may have more features than ES.
Upvotes: 4