PDA

View Full Version : Correct lighting of second texture



Andy2709
02-02-2010, 07:58 AM
Hello. I'm trying to draw Earth with two textures - surface map and cloud map with lighting. Surface is being drawn with GL_MODULATE mode, and it's lighting is OK, but I have to specify GL_DECAL for the cloud map, because GL_MODULATE gives weird result for me. The only problem is there is no lighting for cloud map in GL_DECAL mode. This is the code fragment:


if (earthtex[ti])
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, earthtex[ti]);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
if (cloudtex[ti])
{
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glEnable(GL_ALPHA_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(1.0f, 1.0f , 1.0f, 1.00f);
glBindTexture(GL_TEXTURE_2D, cloudtex[ti]);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glActiveTextureARB(GL_TEXTURE0_ARB);
}
}


Both textures are in ARGB format, but only the cloud map has real alpha component.

The resulting image is here

http://www.anuko.com/img/decal.jpg.

And the image with GL_MODULATE for upper part is here:
http://www.anuko.com/img/modulate.jpg.

It blends with blue color of the "atmosphere".

What I'm doing wrong? How to do correct lighting for the cloud map?

Thanks,

Andy