please forgive me. this is my first post.
I’m trying to draw two polygons on top of each other (same Z value) and use glBendFunc to have them blend correctly. i use two seperate shaders for the 2 polygons. as polygon A has a RGBA texture map associated with it. and polygon B only has color associated with it.
basically i want to use the glBendFunc to blend a color on top of the texture. so if the alpha of polygon B is 1.0 only the color from polygon B is shown. otherwise it is a mix of the two colors from polygonA’s texture and polygon B’s color.
in pseudo code a do the following
drawScene()
{
disableZBuffer();
drawTexturedPolygon();
glEnable(GL_BLENDING);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
drawColoredPolygonWithColor(0.0 /*r*/, 0.0 /*g*/, 0.0 /*b*/, currAlpha);
glDisable(GL_BLENDING);
enableZBuffer();
}
as it is right now i get either polygon A or polygon B they are not blended together.
polygon A’s fragment shader is
precision highp float;
uniform sampler2D texture;
varying vec2 uvPos;
void main( void )
{
gl_FragColor = texture2D( texture, uvPos);
}
polygon B’s fragment shader is
precision mediump float;
varying vec4 vertColor;
void main( void )
{
gl_FragColor = vertColor;
}
would anyone be able to assist me?
thank you everyone for reading.