blending from one texture to another accross the face of a polygon - quickly?

Hello all,

Does anybody have an idea on how I can blend from one texture to another accross the face of a polygon-quickly (i.e. so I could, for example, fade from texture A at the left edge of the polygon to another texture B at the right side of the polygon). I know I can do it in two passes using blending and alpha channels, but I would like to do it in one pass - I just can’t coax ARB Multitexturing into doing it automatically. Maybe it just can’t be done which would be unfortunate for me.

Any enlightenment is appreciated.

Ahahahah !!
Well, it’s seems that many of us are looking for the holy grail !! Unfortunatly, it’s seems that this kinf of operation cant be done in one pass… :frowning:

I know I can do it in two passes using blending and alpha channels

You know the deal…

The first thing I thought about was: Use a greyscale mask, and blend the two textures with respect to the mask. Like (T1G)+(T2(1-G)). But, no no, this is three textures and two passes.

What MIGHT be possible, is to use the same foruma i mentioned above, but change G (the greyscale mask) to C - as in polygon color. I have tried several times to come up with a function to do this.

This way you might, with proper setup, be able to blend two textures without using a third mask (and also a second pass).

IF it’s possible, I would also be glad to know how.

Ummm, how about using the interpolation mode of the COMBINE extension? That requires only 2 textures and one pass. I’d set the first stage to replace mode, and the second stage to combine mode using the interpolation function. For the interpolation function: Arg0 * Arg2 + Arg1 * (1 - Arg2), set Arg0 to previous stage output, Arg1 to texture, and Arg2 to primary color (of which only the alpha component will be used since Arg2 is limited to using only alpha). Now you can control the blending of your textures simply by setting the primary color’s alpha at each vertex.

There’s probably some reason that this won’t work, since you guys haven’t thought of it, but if you have register combiners available, I think this trick would be pretty easy.

Just give the polygon a grayscale color (black on one side, white on the other). OpenGL will smooth this color across the polygon for you. Have the register combiners multiply this color times the first texture and add (1-color) times the second texture. Sum these two resultant colors and you’re set.

You may also be able to do what you want with just the alpha component of the color, so then you could use OGL lighting as well. I am less experienced with using the alpha register combiner, though.

If you have a GeForce so this can work and don’t know how to use register combiners, say so here and I’ll write up some code for you.


That kind of problems where the ones that gave birth to ARB_multitexture extension. I dont think there is a basic-opengl-set single pass solution. Either way, all cards except the oldest ones support multitexture, so why not use it?