Blending with 2 polygons

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

  drawColoredPolygonWithColor(0.0 /*r*/, 0.0 /*g*/, 0.0 /*b*/, currAlpha);

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.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.