texture_env_combine, yet again

Where can I find documents that explains usage of extensions, particularly ARB_texture_env_combine? A document that explains “how, for what, why” type of questions.

The docs say that the first line of the following code must be called. Why? To initialize the combiner? How do you disable them after?

What is operand? What is source?

This is suppose to be part of 1.3 now, no? My driver is 1.3 and it has it listed as an extension.

Thanks,
V-man


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_PRIMARY_COLOR_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA);

mark kilguard has written a page (www.opengl.org right side i believe) also check the faq

even though its part of gl 1.3 under windows to use it u have to treat it as a extension (to gain access to it)

some easy examples

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);

is eqivulant to

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );

ie all it does is replace whatevers in the framebuffer with the texture (ignoring colour/lighting)
not very exciting aye but u can change glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR); to glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_ONE_MINUS_SRC_COLOR); now the framebuffer will be replace by the colour values of 1.0-texture

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PRIMARY_COLOR_ARB);
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);

is eqivulant to

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );

the combine method is a lot more typing out but its also more clear as whats happening ie src0 the colour is getting modulated by the texture thus colour * texture

etc
check the spec it becomes easier once u get a foothold

>>>>>>glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PRIMARY_COLOR_ARB);
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);
<<<<<

equivalent? you are already calling
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);

So what this code does is
“activate combiners”
“source0 is vertex color”
“operand0 is source color” ???
“source1 is texture”
“operand1 is source color” ???
“source0 * source1” or is it
“operand0 * operand1”

why do you need the lines marked with ???
How to turn off the combiner now?

I will search for docs here now…

V-man

It’s been a while since I’ve used this extension…
You use GL_SOURCEx_RGB and GL_SOURCEx_ALPHA to specify where the data comes from for the RGB and ALPHA portions respectively. Imagine you want to use the alpha part of the primary color ( RGBA specified using glColor4f … ) in your RGB part - this you accomplish by using GL_SRC_ALPHA for GL_OPERANDx_RGB.

V-man,
You don’t really turn off the combiners - simply set the combiner mode to it’s default ( GL_MODULATE for texenv0 and GL_REPLACE for subsequent texenv’s ).

Still having some troubles:

Im trying to modulate 2 textures together, and not using the primary color. Is the following correct:

glActiveTextureARB(GL_TEXTURE0_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);

glActiveTextureARB(GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);

Do I need to call
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);

for each unit? and do the locations of the calls to glActiveTextureARB make sense.

Yes, I realized the thing about disabling the combiners, but does each tex unit have its own environment? Im guessing yes.

V-man

That looks correct ( RGB = Tex0*Tex1 ). Yes, you need to set the texture environment mode for each unit ( as you are doing now ).

But you can, if you like, use GL_COMBINE_ARB for one texenv and simply GL_REPLACE for another.
For example, you could use this for the first part,

glActiveTextureARB( GL_TEXTURE0_ARB );
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );

Things you should check: make sure the scaling factors are 1.0 ( default ) for each texenv , enable the appropriate texture targets and remember to set the active texture back to 0 ( I always setup this type of stuff in reverse ).

Yea, I guess REPLACE may be faster (or simply more logical).

This extension again brought up the question of ARB vs EXT vs neutral for me.
I decided to remove all the ARB suffix. Why put all this stuff, and they all have the same value in my glext.h file?

I did the same for the multitexturing. The 50 or so functions have the non-ARB versions defined in glext.h
My code looks cleaner this way. … and if its suppose to be part of GL now then …

I reallly hope that GL 2 will clean up all this clutter.

V-man