How to enable lighting in Texture Units

Started by
6 comments, last by Boltimus 14 years, 10 months ago
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!!
~Bolt"All men dream: but not equally. Those who dream by night in the dusty recesses of their minds wake in the day to find that it was vanity: but the dreamers of the day are dangerous men, for they may act their dreams with open eyes, to make it possible." This I did...
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 .... :
~Bolt"All men dream: but not equally. Those who dream by night in the dusty recesses of their minds wake in the day to find that it was vanity: but the dreamers of the day are dangerous men, for they may act their dreams with open eyes, to make it possible." This I did...
Are you using GL ES 1.1?
You don`t have shader support?
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Seriously, how is it 2009 and someone still isn't writing shaders?
Maybe they're still learning stuff perhaps?

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 ...

~Bolt"All men dream: but not equally. Those who dream by night in the dusty recesses of their minds wake in the day to find that it was vanity: but the dreamers of the day are dangerous men, for they may act their dreams with open eyes, to make it possible." This I did...
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);
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
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....
~Bolt"All men dream: but not equally. Those who dream by night in the dusty recesses of their minds wake in the day to find that it was vanity: but the dreamers of the day are dangerous men, for they may act their dreams with open eyes, to make it possible." This I did...

This topic is closed to new replies.

Advertisement