Failing at this after too many days of experimenting/googling/red book digging:
I have several monochromatic (grayscale) source images that I would like to each blend with a different color and then render all to the screen on a simple quad.
I’m trying to use multitexturing with a pre-defined blend of each texture to a unique color. Here is the gist for two of the textures:
float[] red = { 1f, 0f, 0f, 1f };
float[] green = {0f, 1f, 0f, 1f};
// (ultimately, with your help, I’ll have 5-9 textures and several colors - oranges, purples etc.)
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, redTexture.getID());
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, red, 0);
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
glActiveTexture(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, greenTexture.getID());
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, green, 0);
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE1);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
// The rendering is boilerplate.
The result I get is a great superposition of the two textures on the screen (I’ve done this for as many as I want) but they are all colored with the last color defined in texenv rather than independently colored (i.e. both textures are colored green in the example above).
I was under the impression that each texture environment would be independent using glActiveTexture(), but I’m missing something. Perhaps I need to identify each GL_CONSTANT uniquely???
I had a quick crack at the glBlend - equivalent results.
Also tried glSecondaryColor - brain not big enough to understand the mess that comes out.
I’ve only really found alpha blending examples which really aren’t what I’m after. I need tex1color1 + tex2color2 + …
(the bright areas of each texture are rarely co-localized spatially - lots of low gray values/background in each texture).
Help?
THANKS.