Hello all,
I would like to deal with multi-pass texturing in order my program can render a heavy textured mesh on any hardware.
But I have difficulties to replace my multitexturing code (just 2 textures for testing) by multi-pass rendeing using 1 texture each pass. The rendered image simply do not look as the 1-pass version of it.
Here some points I don’t understand:
-
Why must I have to use glBlend() for multi-pass, since glTexEnv should (See 2) blend the texture correctly? and what parameters should I specify for glBlendFunc()?
-
Why glTexEnv calls don’t work with multi-pass? Should I have to emulate glTexEnv using just glBlendFunc() ??? it seams impossible.
-
May be my problem came from ARB_texture_env_combine which don’t work with just 1 pass?
-
Solution? (I don’t want using Pixel Shader).
My code for multitexturing
// For Unit 0
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_REPLACE);
glBindTexture(...);
glClientActiveTextureARB(GL_TEXTURE0_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, ...);
// For Unit 1
// Same as unit 0 but replacing GL_REPLACE by GL_MODULATE and add:
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2.f);
// Render the mesh
glDrawElements(...);
// For Unit 1
glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_2D);
glClientActiveTextureARB(GL_TEXTURE1_ARB);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
// Disable Unit 0
// Same as for unit 1
Multi-pass texturing which don’t work…
// For the first pass
glDisable(GL_LIGHTING);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_REPLACE);
glBindTexture(...);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, ...);
// Render 1
glDrawElements(...);
// For the second pass
glEnable(GL_LIGHTING);
glDepthFunc(GL_EQUAL);
glDepthMask(GL_FALSE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2.f);
glBindTexture(...);
glClientActiveTextureARB(GL_TEXTURE1_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, ...);
// Render 2
glEnable(GL_BLEND);
glBlendFunc(???, ???);
glDrawElements(...);
glDisable(GL_BLEND);
// Restore states & clean all (depth mask, etc.)
Thanks a lot in advance if someone could help me.