Jump to content
  • Advertisement
Sign in to follow this  
Boltimus

OpenGL How to enable lighting in Texture Units

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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....

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!