Multitexturing woes

I am attempting to use a GLSL fragment shader to do some multitexturing (among other things). But no matter what I do, I can’t seem to get my shader to reference more than one sampler.

The hardware I am using is an NVIDIA GeForce GTX 285 (driver version 195.62)

Here is the shader:


#version 120

uniform vec4 uScale;
uniform vec4 uOverlayColor;
uniform vec4 uWeatherOverlayColor;
uniform float uGammaPower;
uniform sampler2D uFrame;
uniform sampler2D uWarpBlend;
uniform sampler2D uPoissonNoise;

void main()
{
    gl_FragColor.r = texture2D( uFrame, gl_TexCoord[0].st ).g;
    gl_FragColor.g = texture2D( uWarpBlend, gl_TexCoord[0].st ).r;
    gl_FragColor.b = texture2D( uWarpBlend, gl_TexCoord[0].st ).g;
    gl_FragColor.a = 1.0;
}

The reason for the extra uniforms is because the shader is not fully implemented yet, just putting in test code for now to make sure both textures are being referenced.

This is the code I am currently using to set up the textures:


glActiveTexture( 0 );
glBindTexture( GL_TEXTURE_2D, mCoreTextureID[eCoreTextureOffScreenBuffer] );
glUniform1i( currentWarpBlend->mColorTexture, 0 );
glActiveTexture( 1 );
glBindTexture( GL_TEXTURE_2D, mCoreTextureID[eCoreTextureWarpBlend] );
glUniform1i( currentWarpBlend->mDistortTexture, 1 );

If I do this, the texture that should be drawing into the green and blue channels is drawing into the red channel. Nothing is drawing into the green and blue channels.

If I use the following setup code instead:


glActiveTexture( 1 );
glBindTexture( GL_TEXTURE_2D, mCoreTextureID[eCoreTextureWarpBlend] );
glUniform1i( currentWarpBlend->mDistortTexture, 1 );
glActiveTexture( 0 );
glBindTexture( GL_TEXTURE_2D, mCoreTextureID[eCoreTextureOffScreenBuffer] );
glUniform1i( currentWarpBlend->mColorTexture, 0 );

The correct texture is now drawing into the red channel, green and blue are still back, even though both textures are being set to the exact same samplers as before. Shouldn’t both setups be exactly the same?

did u try this :

//bind textures on unit 0 and 1
glActiveTexture( 0 );
glBindTexture( GL_TEXTURE_2D, mCoreTextureID[eCoreTextureOffScreenBuffer] );
glActiveTexture( 1 );
glBindTexture( GL_TEXTURE_2D, mCoreTextureID[eCoreTextureWarpBlend] );

//check if uniforms variables are found
GLint loc;
loc = glGetUniformLocation (urProgram,“uFrame”);
if(loc==-1) printf(“uniform variable not found!”);
glUniform1i(“uFrame”, 0);

loc = glGetUniformLocation(urProgram,“uWarpBlend”);
if(loc==-1) printf(“uniform variable not found!”);
glUniform1i(“uWarpBlend”, 1);

Yes. They have values of 0 and 1.

Got it figured out. Wasn’t using the proper value with glActiveTexture().