Nope, GL_EXT_texture_env_combine is not flexible enough to do that. It only does combinations of the form Arg0Arg1+Arg2. You need Arg0Arg1+Arg2*Arg3. NVIDIA cards starting with the TNT and moving forward, support an extension to do those types of combinations, GL_NV_texture_env_combine4. I’m sure some other video cards must have something similiar.
Yes, I think it is flexible enough. He wants to do Tex0srcAlpha + Tex1(1-srcAlpha). GL_EXT_texture_env_combine defines a GL_INTERPOLATE_EXT mode that performs
Arg0 * (Arg2) + Arg1 * (1-Arg2)
Maybe I’m wrong ,but the arg2 argument is restricted only to the alpha component of the corresponding source. The source above doesn’t say anything about the TexEnvf of the first pass, but I think that the first rendering pass draw the object normally (modulated or decal) and the second pass use the alpha component of the first texture as a mask to draw the second texture.
If that’s the case then you want PRIMARY_COLOR *Tex0_RGB + Tex1_ RGB *(1-srcAlpha).
This is something you can’t do with GL_EXT_texture_env_combine with one pass,but only with GL_NV_texture_env_combine4 or the register combiners.
[This message has been edited by pavlos (edited 09-25-2000).]
It appears to me that he isnt specifying any color component in the first pass before calling Draw_Object(). And I can argue that he must not be setting the color inside Draw_Object, because then that would override his call to glColor4f in the second pass. Therefore, I conclude that in his scenario, pass 1 is a replace with blend and pass 2 is a modulate with an alpha blend. This can be done with GL_EXT_texture_env_combine in one pass. If he intended something else, then the code wasnt clear enough to me.
Actually, I am setting the color in Draw_Object(), I just places glColor4f outside for illustration purposes – the alpha color in the first pass is ignored, so I left out glColor. You could assume it is the same:
glColor(1.f, 1.f, 1.f, 0.5);
Could you give me some pseudo-code for GL_EXT_texture_env_combine?
Also any good examples out there or theory on texture_env_combine?
Ok, after tinker with GL_COMBINE_EXT I figured it out a quick-and-dirty fix. Althrough the alpha values are flipped, I could solve this with glColor(1.f, 1.f, 1.f, 1-a);
Here it is:
for TEXTUREUNIT0, use:
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture();
glTexEnvi(GL_TEXTURE_ENV,
GL_TEXTURE_ENV_MODE, GL_REPLACE);