Multipass texturing

Hello all,

I am trying to use a texture to modulate another texture before I apply it to a model, but with no great success. Is there a way to perform this without using the ARB multitexturing extensions? I was thinking something like multipass texturing, if possible.

Thanks a lot for your help!!

Kostas.

yes, multipass + blending.
but multitexturing is mush faster an more powerfull (with extension like GL_ARB_texture_env_combine).

Yeah I wouldn’t recommend doing multipass for multitexturing since the multitexturing extension exists and is a MUCH faster way than multi passing. Now if you needed to apply more textures than your card can support at once then you would need to multi pass, but still don’t need a pass for each texture. Say you have a 4 texture card and a surface you’re rendering needs to have 6 textures applied to it. Then this would only need 2 passes using the multitexture extension. If you did each texture in its own pass, you’re looking at 6 passes. Much more than what’s needed there.

-SirKnight

The code I am using to modulate the two textures is:

if(pass==0)
{
glBindTexture(GL_TEXTURE_2D, openGLName[1]);
glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glDepthFunc(GL_LEQUAL);
glDepthMask(GL_TRUE);
glBlendFunc(GL_ONE, GL_ZERO);
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE, GL_REPLACE );
}
else
{
glBindTexture(GL_TEXTURE_2D, openGLName[0]);
glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glDepthMask(GL_FALSE);
glDepthFunc(GL_EQUAL);
glBlendFunc(GL_DST_COLOR,GL_ZERO);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
}
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_NOTEQUAL,0);

Both textures contain transparent portions, but ONLY the transparency of the first pass
is taken into consideration. This shouldn’t be the case though since I am multiplying RGBA by RGBA in each texture so the zero alpha in the first should zero the alpha in the second. Am i missing something here?

Thanks again,

Kostas.

First, I wouldn’t draw using GL_BLEND and then a blend function of ONE,ZERO. That’s just inefficiency for no reason.

Second, if you look at the OpenGL fixed-function rasterization pipe (which is a very basic part of the spec and probably not really an “advanced” topic) you’ll see that alpha test happens before framebuffer blend. In fact, pretty much EVERYTHING happens before framebuffer blend.

The reason your first alpha test works for the second pass at all is probably that you use DepthFunc of EQUAL in the second pass, and depth doesn’t get written for alpha-test-failed fragments.

Maybe the texture blending subject isn’t advanced, but it looks quite advanced to me! :wink:

Is there a text/article online somewhere that describes all these methods for texture blending?

Thanks!!

http://www.opengl.org/developers/documentation/index.html