my goal is to render a shaded (using GL-rendered vertex lighting) multi-textured polygon. each texture covers a portion of the polygon; when combined, the textures cover the polygon entirely.
without lighting, i used GL_DECAL to get the desired effect (where the current texture is transparent, the source color shows through). naturally with lighting this causes the lighting to disappear. i need a more complex operation.
so… texture combiners then. what i’d like to achieve is a blending mode in which the texture fragments are multiplied against their alpha, and the sum of the results are multiplied against the fragment’s primary color.
in the style of tables 9-4 and 9-5 in the red book (3rd ed; tables 9-2 and 9-3 in 2nd ed.), the mode i’m looking for is something like:
<pre>
C = Cf * (Ct1 * At1 + Ct2 * At2 + … + Ctn * Atn)
A = Af
</pre>
(note that the distributitive property can be used with C, so that the contribution of each texture to the final sum can be calculated independantly)
i’ve established that the following code produces what i want for a single texture:
<pre>
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PRIMARY_COLOR_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
</pre>
i need to somehow add the results of PREVIOUS_EXT for all but the first texture, and i’m not exactly sure how to go about this.
i’d be grateful for a clue.