I'm trying to use OpenGL and framebuffer/texturebuffer objects to composite some 2D mask images.
At the moment, I'm creating a new destination texture and binding it to a framebuffer so it will accumulate the final mask. Then I iterate through all my source textures and draw them one at a time on top of my destination texture. (I'm doing this by drawing a singe quad with a simple shader that just samples the source texture).
While this works well for simple alpha blending, I would like to be able to create more complex operations that use the current color of the destination pixel to calculate the color of the current fragment. For example, I would like to do something like:
Code :vec4 src = texture2D(u_mySrcTex, v_samplingCoord); vec4 dst = getCurrentColorAtOutputFragmentPosition(); vec4 finalColor = vec4(dst.rgb, max(src.a, dst.a));
I'd also like to be able to implement Porter-Duff compositing and things like that.