Odd problem with MultiTex and lighting

Ok, this one has me stumped. I’m working on a project that applies two textures (using the extensions) to some terrain. Now, I have a specular lighting component that works fine when there are no textures being applied or when only my spheremapped texture is being applied. However, when I add a second (fixed) texture to the surface, I can no longer see my specular lighting.

It’s actually even weirder than that. If I rotate the entire thing around, there are some angles where I CAN see the specular light shining through the second texture (it is a different color and I am using SEPARATE_SPECULAR_COLOR so it is really apparent). Toggling this texture on and off confirms that it shows specularity in a different orientation than my geometry does. Any ideas at all about what could be causing this?

Thanks,
Zeno

Not sure what’s causing it, but here’s one way to analyze the problem. Try setting up all your texture environments to GL_ADD (assuming support for that extension).

Try toggling on and off all the textures.

Try loading up each textures as all black.

Also make sure to try enabling texture 1 but not texture 0.

If things are working properly, a black texture and a disabled texture should be equivalent with an ADD environment. If not, you’ll see the lighting change when the texture gets enabled.

Beyond that, I can’t help given the information provided…

  • Matt

Thanks for the help It led me to find the bug.

Here is a brief outline of what the bug was in bad pseudo-code:

void render_texture()
{
push matrix;
set up modelview and projection matrices for this viewpoint;
gl position light at lightposition;
draw stuff;
pop matrix;
}

void display()
{
set up modelview and projection matrices
for this viewpoint;
gl position light at lightposition;

if(texture_enabled)
render_texture();

draw geometry with 2 textures;
}

As you probably noticed from above, enabling the second texture will put the light in a different position because of the different modelview and projection matrices. The simple fix was to move the positioning of my light to after the call to render_texture() in display(). Silly bug took me a day to find.

I don’t know how many people will read this note since it is no longer a new post, but I wanted to say thanks to all of the OpenGL experts here who contribute their time to helping people with their OpenGL coding problems…Mcraighead, Bob, DoloMighty, Dfrey, and all of the others that I can’t remember right now. I’ve seen you post huge code snippets for others that must have taken a good hour to write and debug (if you did it just then). Anyway, you obviously don’t have to do this, and I just wanted to let you know that your help is greatly appreciated, especially by those of us who don’t personally know anyone offline who can help with such specific OpenGL questions.

–Zeno

Just wanting to add a thankyou onto Zeno’s to all you guys there that take your time to help us not-so-clued-upTM programmers.

It’s really appreciated, and makes the learning process that much easier and more enjoyable, so thanks!

“But explain to me once what this new formality is, which has to be gone through, as you say; and it shall be done at once.”
“Do you know how many separating impediments are there?”
“What would you have me know about impediments?”
“Error, conditio, votum, cognatio, crimen, cultus disparitas, vis, ordo… Si sit affinis…” began don Abbondio, counting on the tip of his fingers.
"Are you making game of me? Interrupted the young man.
“What do you want me to do with your latinorum?”
“Then, if you don’t understand things, have patience, and leave them to those who do.”