Sign in to follow this  
Chozo

Multitexturing and lighting?

Recommended Posts

Chozo    176
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?

Share this post


Link to post
Share on other sites
hplus0603    11356
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.

Share this post


Link to post
Share on other sites
Chozo    176
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?

Share this post


Link to post
Share on other sites
Chozo    176
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?

Share this post


Link to post
Share on other sites
jjmontes    158
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?

Share this post


Link to post
Share on other sites
Chozo    176
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.

Share this post


Link to post
Share on other sites
Zongo    208
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.

Share this post


Link to post
Share on other sites
Chozo    176
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]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this