PDA

View Full Version : Problem: Multitexture affect Lighting



Visualc++
09-18-2002, 10:33 AM
i'm using multitexture for create lightmaps, but to aply the multitexture in the terrain lighting not working...
this image is before aply multitexture: http://www5.gratisweb.com/visualc/before.JPG
this is aply multitexture to the terrain http://www5.gratisweb.com/visualc/after.JPG

the multitexture code is this:

GLint Gen3DObjectListTerreno()
{


GLuint texture_name;
GLuint texture_name2;



glGenTextures(1,&texture_name);
texture_mapsTerreno[0].id=texture_name;
glBindTexture(GL_TEXTURE_2D,texture_name);
LoadTextureTerreno(texture_mapsTerreno[0].name);

glGenTextures(1,&texture_name2);
texture_mapsTerreno[1].id=texture_name2;
glBindTexture(GL_TEXTURE_2D,texture_name2);
LoadTextureTerreno(texture_mapsTerreno[1].name);


GLint lid=glGenLists(1);

glNewList(lid, GL_COMPILE);


glEnable(GL_BLEND);
glDisable(GL_LIGHTING);
glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, texture_mapsTerreno[0].id );
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glEnable(GL_TEXTURE_2D);


glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_2D, texture_mapsTerreno[1].id );
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_TEXTURE_2D);

glBegin(GL_QUADS);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.03125, 0.03125);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 0.0);
glVertex3f(0.2, 0.2, 0.0);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.65625, 0.03125);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, 0.0);
glVertex3f(0.8, 0.2, 0.0);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.65625, 0.65625);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, 1.0);
glVertex3f(0.8, 0.8, 0.0);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.03125, 0.65625);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 1.0);
glVertex3f(0.2, 0.8, 0.0);
glEnd();

// glFlush();
glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE0_ARB);
glDisable(GL_BLEND);
glEnable(GL_LIGHTING);
glEndList();

return lid;
};

any idea?

Mazy
09-18-2002, 11:23 PM
the line
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

effectivly tells opengl to discard the polygoncolor, also used for lighting.

use gl_modulate instead