   gl_MultiTexCoord0.st weird behavior in GLSL
  Hey there , I just wrote a simple shader program in GLSL:varying vec2 TexCoord0;varying vec2 TexCoord1;void main(){TexCoord0= gl_MultiTexCoord0.st;TexCoord1= gl_MultiTexCoord1.st;gl_Position=ftransform();}The fragment shader is as follows:uniform sampler2D SMP0;uniform sampler2D SMP1;varying vec2 TexCoord0;varying vec2 TexCoord1;void main(){vec3 PixelData0 = texture2D(SMP0,TexCoord0).rgb;vec3 PixelData1 = texture2D(SMP1,TexCoord1).rgb;vec3 PixelData = PixelData0 - PixelData1;gl_FragColor = vec4(PixelData, 1.0);}As you can see , in the fragment shader I sample two textures. When I am using: "TexCoord0 = gl_MultiTexCoord0.st;" in the vertex shader it seems that the shader does not correctly read the GL_TEXTURE0 Texture unit, It rather seems to read a Black texture. However if I use instead:"TexCoord0 = gl_MultiTexCoord1.st;" or "TexCoord0 = gl_MultiTexCoord2.st;" etc...Everything works fine. I suspect it works fine because the textures in all my texture units are of the same size, I do not know however why it isn't functioning at all with TexCoord0 = gl_MultiTexCoord0.st; Any clues?   
  youre confusing texture coordinate with texture unitsusually u access multiple textures (texture units) at once but use the same texture coordinates   ;  What do you mean by "confusing"? I thought that gl_MultiTexCoord0.st refers to Texture Unit 0 , gl_MultiTexCoord1.st to Texture Unit 1 etc.  Isn't that right? Regardless , why does the shader not work properly with gl_MultiTexCoord0.st ?   ;  some rendering code to show how you pass things down would be handy...   ;  Ok here's the code :)void display(){glActiveTexture(GL_TEXTURE3);glEnable(GL_TEXTURE_2D);glBindTexture(GL_TEXTURE_2D,texNames[3]);glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE);glMatrixMode(GL_PROJECTION);glLoadIdentity();gluOrtho2D(0.0, TextureWidth, 0.0, TextureHeight);glMatrixMode(GL_MODELVIEW);glLoadIdentity();glViewport(0, 0, TextureWidth, TextureHeight);glPolygonMode(GL_FRONT,GL_FILL);glColor3f(1.0, 0.0, 0.0);glBegin(GL_QUADS);glTexCoord2f(0.0, 0.0); glVertex2f(0.0, 0.0);glTexCoord2f(TextureWidth, 0.0); glVertex2f(TextureWidth, 0.0);glTexCoord2f(TextureWidth, TextureHeight);glVertex2f(TextureWidth, TextureHeight);glTexCoord2f(0.0, TextureHeight);glVertex2f(0.0, TextureHeight);glEnd();glFlush();glDisable(GL_TEXTURE_2D);};  According to your rendering code, only texture unit 3 is getting Texture coordiates( at least thats what I'm seeing ), and unless your setting your uniforms eariler (such as your Shader setup) your texture data is all coming from unit0 , your code has a very limited scope so I'm extrapolateing a bit...   ;  I still didn't manage to make things work... :(I'm sure I'm missing something important here. Let's put it another way:Do I use gl_MultiTexCoordN.st to adress texture unit N or not?   ;Quote:Original post by GorgiI still didn't manage to make things work... :(I'm sure I'm missing something important here. Let's put it another way:Do I use gl_MultiTexCoordN.st to adress texture unit N or not?To address the texture coords for texture unit N, yes.  However you are only setting one set of texture coordinates in your example code.  To set a texture coordinate set for texture unit 1, you'd have to use:glMultiTexCoord2f( 1, s, t );However you don't HAVE to use texture coordinate set N to sample texture unit N.  If the coordinates are supposed to be the same for both units, you could just set them for unit 0 and use gl_MultiTexCoord0.st for both texture2D calls.(Edited, looks like I got how this works a little wrong the first time, should be correct now.);Quote:Original post by lancektglMultiTexCoord2f( 1, s, t );For sake of correctness - this should be glMultiTexCoord2f(GL_TEXTURE1, s, t);.Gorgi: In your vertex shader just useTexCoord1 = TexCoord0;which is what lancekt said I think. In any case if you are using multitexturing, it's clearer to use glMultiTexCoord in your code. I'm not sure if glTexCoord addresses texture unit 0 or the currently active texture unit.   ;  There is a difference between Texture units and Texture coordinates, the texture coordinates you pass with the vertices are bound to the active texture-unit(usually 0) if you don't use glMultiTexCoord. And as the others said, for Multitextureing you usually don't need several sets of texture coordinates either, because the textures from the different texture units are mapped onto each other.So if the active Texture unit(your code shows binding only one texture, i guess you use glActiveTexture somewhere..??) is not the one with No 0, you won't get more sets of texture coordinates. so just use the same set of coordinates for both samplers, because these do not depend on where the coordinates come from.   