How can I efficently interpolate per-pixel two textures A and B by a dynamic texture C and draw them on a simple quad? Multi-pass algorithms accepted.
I've had moderate success calculating the C texture per-frame on the CPU and uploading it with glTexImage2D
into an alpha-only texture.
While this worked, performance was lacking and I had to reduce the dimensions of C to half of the full size to get around the copying bandwidth bottleneck.
So, for performance reasons, I'm trying to do all of my C texture updates using render-to-texture.
I was able to set up the necessary buffers for rendering, but fundamentally, I get a texture in RGB or RGBA format with the mask encoded in lightness/RGB information, not alpha.
How do I convert this efficiently into the alpha texture I need to plug into the texturing pipeline? Keep in mind that there is no programmable pipeline (shaders) and only two texture units available on the iPhone.
Update: A and B are RGB-only textures, ie no alpha.