texture_env_combine

im working on how this extensions works:
http://oss.sgi.com/projects/ogl-sample/registry/EXT/texture_env_combine.txt

its a bit vague:

lets say for example i have a texture 0 and texture 1

texture 0 is some texture map with a mask alpha map
texture 1 is some other rgb texture

i want to have texture 1 show through texture 0 where the alpha is appropriately set.

so it would be:
environment mode: INTERPOLATE_EXT
Arg0 * (Arg2) + Arg1 * (1-Arg2)

so arg0 should be texture0 rgb and arg2 will be alpha from texture 0,

arg1 will be texture1 rgb

so how do i tell this to opengl through this extension? and also combine it with the incomming light colour?

Originally posted by supagu:
[b]im working on how this extensions works:
http://oss.sgi.com/projects/ogl-sample/registry/EXT/texture_env_combine.txt

its a bit vague:

lets say for example i have a texture 0 and texture 1

texture 0 is some texture map with a mask alpha map
texture 1 is some other rgb texture

i want to have texture 1 show through texture 0 where the alpha is appropriately set.

so it would be:
environment mode: INTERPOLATE_EXT
Arg0 * (Arg2) + Arg1 * (1-Arg2)

so arg0 should be texture0 rgb and arg2 will be alpha from texture 0,

arg1 will be texture1 rgb

so how do i tell this to opengl through this extension? and also combine it with the incomming light colour?[/b]
Never used this extension so maybe I’m wrong but it seems pretty straightforward :
bind texture0 to texture unit 0
set TEXTURE_ENV_MODE to GL_REPLACE

bind texture 1 to texture unit 1
enable texture_env_combine and set it to mode interpolate like this :

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_INTERPOLATE_EXT);  

source 0 is the color from the previous texture unit :

	glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT);
	glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);

source 1 is the color from the texture bound to the current texture unit :

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
	glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);

source 2 is the alpha from the previous texture unit :

	glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PREVIOUS_EXT);
	glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA);

And you’re done :slight_smile:
As I previously said I’m not sure this is working but it seems logical.

btw check the ARB version of that extension, I think it can do a little bit more

also ATI has some demos about EXT version useage and source up (old rage sdk)
http://www.ati.com/developer/sdk/rage128sdk/Multex/OGLMultex.html

http://www.ati.com/developer/sdk/Rage128sdk/intro.html

In order to use two textures in a single texenv you need the crossbar extension. Otherwise you’ll have to use two texture usits and set it up so that the texture result from the first unit feeds into the second unit as the previous parameter (this happens by default as TUs are daisy chained).

dorbie, yeah thats what im trying to do, have 2 tex units and feed results from first to second

downloaded the multitexogl app from ati, it helps clear up a few questions, still seems a bit stubborn trying to get the right effect

Turns out that all cards that matter support the crossbar extension. NVIDIA actually supports it on GeForces and up, but they don’t advertize it, because they are off in the case of texturing from an undefined texture image (or something like that) – they have a NV-specific extension exposed that means the same thing.