Lighting and multitexture

Hi all!

My question is, how can lighting be enabled/disabled for texture units independently. I made a simple app and the rendering code is like following:

  
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[0]);

glActiveTexture(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[1]);
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_ADD);

glBegin(GL_QUADS);
        // Front Face
        glNormal3f( 0.0f, 0.0f, 1.0f);
        glMultiTexCoord2f(GL_TEXTURE0,0.0f, 0.0f);
        glMultiTexCoord2f(GL_TEXTURE1,0.0f, 0.0f); 
        glVertex3f(-1.0f, -1.0f,  1.0f);
        glMultiTexCoord2f(GL_TEXTURE0,1.0f, 0.0f);
        glMultiTexCoord2f(GL_TEXTURE1,1.0f, 0.0f); 
        glVertex3f( 1.0f, -1.0f,  1.0f);
        glMultiTexCoord2f(GL_TEXTURE0,1.0f, 1.0f);
        glMultiTexCoord2f(GL_TEXTURE1,1.0f, 1.0f); 
        glVertex3f( 1.0f,  1.0f,  1.0f);
        glMultiTexCoord2f(GL_TEXTURE0,0.0f, 1.0f);
        glMultiTexCoord2f(GL_TEXTURE1,0.0f, 1.0f); 
        glVertex3f(-1.0f,  1.0f,  1.0f);
        { additional quads }
glEnd();

Now it looks like lighting is only enabled for texture unit 0, and for unit 1 it isn’t. I tried to change mixing mode (eg. GL_REPLACE instead of GL_ADD), and it didn’t change the fact that there is no lighting for unit 1. I got the same result with VBO-s.

Anyone has an idea how I can enable lighting for unit 1?

Thank you in advance.

GL_MODULATE

I believe that the first texture unit receives the fragment color based on material and lighting effects (if lighting is enabled).

GL_MODULATE causes the previous value to be multiplied by the new one.

GL_ADD causes them to be added, thus it is possible to saturate teh value quickly.

FragColor(Includes Lighting)->TexUnit1->TexUnit2

Thus, each texture unit is not individually lit.

Hope that helps…

Thank you, now I understand it.