Skip to main content
gamedev.net
🔒 Locked

GLSL / Multi-texture problem

Started by birdjames Apr 4, 2006 at 7:11 AM 2 replies 2k views
Original Post
birdjames
birdjames
I'm having difficulties with multi-texturing in GLSL. I have binded my textures in the usual way (glActiveTexture, glBindTexture, glEnable(GL_TEXTURE_2D) ) and multi-texturing works for the fixed function pipeline. When I switch to using a shader object, multi-texturing doesn't work! This leads me to believe that either: 1. My GLSL code is incorrect 2. There is something that I haven't done (an OpenGL function I haven't called maybe?) before the geometry is rendered Attached below is a simple fragment shader that should use the first set of texture coordinates to sample the 2D texture binded to GL_TEXTURE1:
uniform sampler2D sampler0, sampler1;
void main ( void )
{
	gl_FragColor = texture2D ( sampler1, gl_TexCoord[0] );
}
What actually happens is no matter which sampler I use for the first argument of 'texture2D', it always samples the 2D texture bound to GL_TEXTURE0. I am definitely binding my textures correctly, as fixed-function works fine. Any help would be much appreciated! Thanks, birdjames.
birdjames
birdjames
Thanks for your quick reply - problem fixed.
birdjames.
deavik
deavik
Glad you got that sorted out! However, it's possible I'm wrojng but I think texture2D(...) expects a vec2 as the second argument. You should really be using gl_TexCoord[0].st

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.