Original Post
I have been having problems with GLSL and multi-texturing. First off, I know my card supports multi-texturing because I have implemented it before without a shader. However, I am trying to do some unique shading with two textures that can't be done with the standard issue texture combining functions. Here is how I initialize my textures Where testTexture1 and testTexture2 are procedurally generated textures meant to be very distinguishable from one another for the purpose of debugging (one of them is perlin noise and the other is solid white). Before rendering, I set up my texture units as follows: In the fragment shader, I set up my samplers as follows From everything I've read or seen about GLSL, this should bind tex1 to GL_TEXTURE0 and tex2 to GL_TEXTURE1. However, the following two statements in the fragment shader will give the exact same value: Any thoughts on this? Is there some arcane state that can screw this up? Have I initialized something wrong? This is extremely frustrating. Rate++ for tips that lead to a solution.
glGenTextures( 1, &fbTexture );
glBindTexture( GL_TEXTURE_2D, fbTexture );
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA,
256, 256,
0, GL_RGBA, GL_UNSIGNED_BYTE, testTexture2 );
glGenTextures( 1, &fbTexture2 );
glBindTexture( GL_TEXTURE_2D, fbTexture2 );
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA,
256, 256,
0, GL_RGBA, GL_UNSIGNED_BYTE, testTexture1 );
glActiveTextureARB(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, fbTexture);
glActiveTextureARB(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, fbTexture2);
uniform sampler2D tex1, tex2;
gl_FragColor.rgb = texture2D(tex1, gl_TexCoord[0].st).rgb; //gives correct output
gl_FragColor.rgb = texture2D(tex2, gl_TexCoord[0].st).rgb; //gives same output as line above, which is highly incorrect, because tex2 != tex1