Skip to main content
gamedev.net
🔒 Locked

Multitexturing and lighting?

Started by Chozo Nov 9, 2004 at 11:26 PM 7 replies 1.6k views
Original Post
Chozo
Chozo
Is there a reason that GL_TEXTURE0_ARB doesn't apply lighting, but GL_TEXTURE1_ARB and GL_TEXTURE2_ARB do? I'm a little baffled by this and it's making things look very odd in my scene. Is it just me or is there something special about the 0 unit?
hplus0603
hplus0603
Read the spec on texture environment application. Specifically, what is the texture env mode on your texture unit 0? Note that the vertex lit color arrives as input to env 0, so if it's REPLACE, lighting will get slammed. You typically want MODULATE.
enum Bool { True, False, FileNotFound };
Chozo
Chozo
Should the env be set each frame or just when the texture is created? I thought by default it was set to modulate, but I load other textures after the one in unit 0 that aren't set to modulate. Would those overwrite what's in unit 0 if I'm setting the env every frame?
_DarkWIng_
_DarkWIng_
Texture env mode is not bound to texture, it's a state. It stays the same until you change it.
You should never let your fears become the boundaries of your dreams.
Chozo
Chozo
Ahh, I had a feeling that's what it was. All the articles I read had it as bound to the texture like glTexParameter options. Let me get back in there and play around with that some more. Thanks for the help.

EDIT - Does glTexParameter actually apply to the currently bound texture with multitexturing? All the examples show glGenTex, glBindTex, glTexParam, gluCreate2DMipmp and then doing it again for other textures, then rendering by setting the current unit, enabling texturing, binding the texture, then repeating for other units, and finally rendering the object. I'm sticking the glTexEnv calls while the units are selected, right before rendering. Is that approach correct?
jjmontes
jjmontes
I'm interested too. It is not clear in the tutorials.

However, from my little experience I would say that no, it is not correct. You should set all the glTexParam and Env stuff for each material and texture unit.

I think that gluCreate2DMipmaps has to be called once, though.

Please can anyone tell how should be done?
-=[ J ]=-I always forget to change the tagline.
Chozo
Chozo
Well, after some research, it looks like that's correct. glTexParam effects the texture functions, not the currently bound texture. So it has to be called on each texture unit (to set the state). In my case, that means every frame.
Zongo
Zongo
I'll try to make things clear:

glActiveTexture changes the current texture unit. Most texturing functions and enables affect the current texture unit only.

glTexEnv changes a state of the texture unit.

glBindTexture binds a texture object to a texture unit.

glTexParameter changes the state of texture objects. The modified texture object is the one currently bound on the active texture unit. Once you set your filtering options on a given texture, you do not have to set it again. But if you want to go from LINEAR to NEAREST, you have to bind the texture object before changing the parameter.
Chozo
Chozo
Is there some documentation somewhere that confirms that? The man page says glTexParameter modifies the given texture target and glBindTexture binds a texture to the given texture target. It seems like glTexParameter has more to do with the state of the texture target and not the object bound to it. I'm not saying I don't believe you, I'd just like to see it confirmed by some authority if I could.

Opengl.org just confirmed what you said. The glTexParameter values are indeed stored with the texture object.

[Edited by - Chozo on November 12, 2004 11:35:52 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.