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:

glBindTexture(GL_TEXTURE_2D, texture[0]);

glBindTexture(GL_TEXTURE_2D, texture[1]);

        // 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 }

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.


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.