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
As I previously said I’m not sure this is working but it seems logical.