I’m trying to achieve the following env.map combination using multitexturing:
basetex + envmap * color
where color is a constant RGBA color.
The trouble I’m having is modulating the envmap texture with the color.
Are there any texture environments in OpenGL that allow an add followed by a modulate? The closest I’ve seen is GL_INTERPOLATE_ARB (in the texture_env_combine ARB extension) but it doesn’t quite do the job.
You say you want base+env*color, and your problem is that you attack the problem in exactly that order. This means you have to load the base texture in the first stage, and then perform an add and a multiply in the second stage.
Now, remeber that A+B is equal to B+A. That would mean you get the same result with the following equation: env*color+base.
This one is easier. Load texture and modulate in first stage, and add in second stage.
glTexEnvi(…, MODULATE); // modulate with primaty color
glTexEnvi(…, GL_ADD); // add base texture
If you want singed add, you can setup the second combiner stage like this instead.
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_ADD_SIGNED);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE);