PDA

View Full Version : Merging textures



yossi
03-31-2001, 10:26 PM
I would like to know if there is a way in OpenGL to do the following effect:
I want to render two textures (#1 and #2) into the same polygon, say triangle with vertices A, B, and C. I want that on vertices A and B I would see 100% of texture #1 and on vertex C - 100% of texture #2. I want a smooth transition from one texture to another e.g in the middle of the triangle I want to see a blending of the two textures, something like interpolating alpha values.
Is there a way to do so in OpenGL?
Many thanks,
Yossi

Zeno
04-01-2001, 12:01 AM
It seems like this question has been asked before...search around for it on this board.

Otherwise:

One option is to pre-generate a single texture that is a combination of the two.

A second option is to use 2 rendering passes. On the first pass, set the alpha value of one of the vertices to 1 and the other two to 0. Apply one texture with mode GL_MODULATE. Now flip the alpha values and render again, blending with the first pass.

Finally, you might be able to do it in one pass with register combiners. Enable multitexturing and register combiners. Set the color value of vertices A and B to 0. Set color of C to 1. Multiply texture0 by the vertex color value and multiply texture1 by (1 - color). This should do what you want in one pass.

-- Zeno