Archived

This topic is now archived and is closed to further replies.

timmie

blending textures via multitexturing

Recommended Posts

I''m trying to do a blend between two textures over time, but am having troubles getting it to look right using multitexturing. This is what I''m trying to emulate:
textureList.BindTexture(tex2, false);
glColor4f(poly->r, poly->g, poly->b, 1.f);
glDrawArrays(GL_TRIANGLE_FAN, poly->index, poly->numPts);
textureList.BindTexture(tex1, false);
glColor4f(poly->r, poly->g, poly->b, alpha);
glDrawArrays(GL_TRIANGLE_FAN, poly->index, poly->numPts);
 
and this is how I''m trying to do it with multitexturing:
colors[0] = poly->r;
colors[1] = poly->g;
colors[2] = poly->b;
colors[3] = alpha;

glActiveTextureARB(GL_TEXTURE0_ARB);
textureList.BindTexture(tex2, false);

glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
textureList.BindTexture(tex1, false);

glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, colors);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_INTERPOLATE_EXT);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_CONSTANT_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_ONE_MINUS_SRC_ALPHA);

glColor4f(poly->r, poly->g, poly->b, poly->a);
glDrawArrays(GL_TRIANGLE_FAN, poly->index, poly->numPts);

glDisable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE0_ARB);
 
The problem is that the multitexuring version gets a funny flicker in it. Video is the best way to illustrate this, so here''s a sample: http://members.shaw.ca/timstump/zdoomgl/multitex.mpg (bad) http://members.shaw.ca/timstump/zdoomgl/nomultitex.mpg (good) Any ideas? Thanks!

Share this post


Link to post
Share on other sites