PDA

View Full Version : multitexturing + blending



HamsterofDeath
02-25-2004, 11:04 AM
is it possible to use blending for lets say 4 textures, and give every textureunit a different alpha-value per vertex ?

soconne
02-27-2004, 06:26 AM
I don't 'think' you can give a different alpha value per vertex with 4 different textures. You might have to use '8' textures, with the other 4 being alpha maps where you map an alpha value from a corresponding pixel to each vertex. Look up texture splatting, http://www.cbloom.com

Aeluned
02-27-2004, 08:25 AM
you can use an interpolating combiner function.
From the OpenGL RedBook:
static GLfloat constColor[4] = {0.,0.,0.,.5};

glTexEnvfv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_COLOR,con stColor);
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvf(GL_TEXTURE_ENV,GL_COMBINE_RGB, GL_INTERPOLATE);
glTexEnvf(GL_TEXTURE_ENV,GL_SOURCE0_RGB,GL_TEXTURE );
glTexEnvf(GL_TEXTURE_ENV,GL_OPERAND0_RGB,GL_SRC_CO LOR);
glTexEnvf(GL_TEXTURE_ENV,GL_SOURCE1_RGB,GL_PREVIOU S);
glTexEnvf(GL_TEXTURE_ENV,GL_OPERAND1_RGB,GL_SRC_CO LOR);
glTexEnvf(GL_TEXTURE_ENV,GL_SOURCE2_RGB,GL_CONSTAN T);
glTexEnvf(GL_TEXTURE_ENV,GL_OPERAND2_RGB,GL_SRC_AL PHA);

The alpha value of the constant color will be the weighting factor for each texture.
change this alpha value between texture units.

[This message has been edited by Aeluned (edited 02-27-2004).]