OpenGL How to enable lighting in Texture Units

This topic is 3330 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

If the only Texture Unit I'm using is 0, lighting sees to take care of itself with the appropriate amount of openGL initialization. If I use multi-texturing and want to use Texture Unit2, how do I get it to be sensitive to lighting. I' running two texture units and am combining them with GL_COMBINE and GL_INTERPOLATE. For now, I'm setting up the combining function such that only texture1 "survives" and is displayed. However it has no lighting. If I change the combiner function so that texture0 "survives" then it has lighting. How do I enable lighting on texture 1 and above? Thanks!!

Share on other sites
Well, I've tried a little tinkering but to no avail. I even tried modulating texture1 with GL_PRIMARY_COLOR and even modulate the alphas, but for some reason I can't get any texture above texture0 to be affected by light. Any texture mapped above texture unit 0 comes on full blast as if ambient was 1.0,1.0,1.0. I'm stuck here .... :

Share on other sites
Are you using GL ES 1.1?
You dont have shader support?

Share on other sites
Seriously, how is it 2009 and someone still isn't writing shaders?

Share on other sites
Maybe they're still learning stuff perhaps?

Share on other sites
V, I'm using JOGL (openGL in Java).

RDragon1, why post? I don't want to write a shader right now because of possible hardware constraints. You're comment wasn't helpful at all. Here's my question to you.. It's 2009, and you don't know how to solve this problem? I sure don't and would appreciate help, just not the saracasm ...

Share on other sites
RDragon1 is correct so don't be against his comment. Everyone has shader capable hardware and a huge number of people have SM 3.0.
Texture combiners is a driver hack that generates shaders under the hood.
Neverthless, since I'm a nice guys, here is one possible solution.
If what you want to do is texture0 * texture1 * lighting_result

glActiveTexture(GL_TEXTURE0);glBindTexture(GL_TEXTURE2D, texID1);glEnable(GL_TEXTURE2D);glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);glActiveTexture(GL_TEXTURE1);glBindTexture(GL_TEXTURE2D, texID2);glEnable(GL_TEXTURE2D);glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);`

Share on other sites
Thx for the response Vman. I'm not so much against the comment that Rdragon said as I was about how unhelpful it was, as I said before. I need help not sarcasm.

Anyhow, I was doing what you recommended. In fact the default is MODULATE if you do not specify anything at all. The problem is texture0 is properly modulated by the light source, but then when texture1 gets modulate by the GL_PREVIOUS fragment it is being modulated by texture0 not just by the light alone. I tried even MODULATING texture1 by GL_PRIMARY_COLOR and it was as if the priary color was 1.0, 1.0, 1.0, 1.0. I may very well have to look at writing shaders, I was hoping I could have gotten away with it here as it has been some time since I last wrote shaders and will have to catch up again....

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 30
• 13
• 11
• 11
• Forum Statistics

• Total Topics
631782
• Total Posts
3002324
×