ARB_Multitexture question: Opacity levels for each active tex unit?

Consider the following code:

void CMyView::LoadTextures()
{
PFNGLACTIVETEXTUREARBPROC glActiveTextureARB = 0;
glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)wglGetProcAddress(“glActiveTextureARB”);

unsigned int * texture1;
int tex1width, tex1height, tex1comps;

unsigned int * texture2;
int tex2width, tex2height, tex2comps;

glGenTextures(1, texObject);

// declare pixel byte order
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

// Bind the texture object and assign texture data and properties
glBindTexture(GL_TEXTURE_2D, texObject[0]);
texture1 = read_texture(“earthmap.rgb”, &tex1width, &tex1height, &tex1comps);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, tex1width, tex1height, GL_RGBA, GL_UNSIGNED_BYTE, texture1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

// Bind the next texture object and repeat the process
glBindTexture(GL_TEXTURE_2D, texObject[1]);
texture2 = read_texture(“spheremap.rgb”, &tex2width, &tex2height, &tex2comps);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, tex2width, tex2height, GL_RGBA, GL_UNSIGNED_BYTE, texture2);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

// Load up the first texture unit and assign the texture object to it
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texObject[0]);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

// Load up the second texture unit and assign the texture object to it
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texObject[1]);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

}

Is there a method to varying the level of opacity for each texture unit? Vis a vis photoshop layers? I just started using true multitexturing (vs. multipass rendering) and I can’t find documentation for this in the Red Book, Blue Book or Foley.vanDam.

Thanks in advance,

Glossifah

[This message has been edited by Glossifah (edited 01-25-2001).]

You can do it by using an RGBA texture with the texture environment set to GL_DECAL. Unfortunately, you won’t be able to use lighting properly with this method.

j

You can use the interpolation operation that is part of GL_EXT_texture_env_combine. If you set the Arg2 source as the texenv color, you can control the mixing of the two textures by adjusting the alpha component of the texenv color. This method will not interfere with lighting.

[This message has been edited by DFrey (edited 01-25-2001).]

Great information!

Thanks,

Glossifah