   blended two textures
  I have two textures with alpha transparency. Texture B is drawn on top of texture A and I want to combine them so that texture B is only drawn where texture A is fully opaque. Is this possible using fixed pipeline (i.e. glTexEnvi, glBlendFunc, etc)?   
  Restricting the usage to the fixed function set, I would then draw texture B first, and then use the alpha test to draw only the partially opaque part of it. The alpha test for texture A, which is drawn second, would be glAlphaFunc(GL_NOTEQUAL, 1).   ;  Thanks for the answer bob, but I can't see how that would work. Let me explain better what I'm trying to do:;  And what does the alpha channels of A and B look like?   ;  Or never mind that question; was a bit distracted when I posted. I assume the alpha channel is correct and masks the shapes properly.Texture A and B can be combined using the texture combiners. You can set the first stage to GL_REPLACE and just output texture A. The second texture RGB combiner uses the GL_INTERPOLATE function to blend between A and B using A's alpha channel. The second texture alpha combiner uses GL_REPLACE to output A's alpha channel. That way, the two textures are blended, but is masked only based on A's alpha channel. That seems to be what you actually want.   ;  Mathematically it looks like//This gives that pill shape with the red and blue partnewcolor.rgb = mix(textureA.rgb, textureB.rgb, textureB.a * textureA.a);//This puts the pill shape on top of the backgroundresultColor.rgb = mix(newcolor.rgb, background.rgb, textureA.a);I don't think it can be done with the fixed pipeline in a single pass because the first equation needs to modulate alpha and then do interpolation.   ;Quote:Original post by V-manI don't think it can be done with the fixed pipeline in a single pass because the first equation needs to modulate alpha and then do interpolation.I just said above how to do it in fixed function.edit: And reason why it can be done is that you shouldn't modulate the alpha in the first interpolation. Interpolating with textureB.a only will combine the two images into one, and the second interpolation masks the combined image using textureA.a.   ;  Unfortunately, I don't really understand texture combiners 100%, but by trial and error I managed to get something to work, not exactly what I wanted, but it'll do the job ;).Thanks very much for your help!   