Here when I am applying scaling, it is applied to both texture 1 and texture 2. But I want to apply the scaling only to texture1 and not 2 and still merge these two on color value on texture 2. I am using multitexture extension.

Well, this has nothing to do with shaders. Simply use the texture matrix and select the appropriate texture unit for each.

Something like:

glActiveTextureARB (GL_TEXTURE0_ARB);
glMatrixMode (GL_TEXTURE);
glLoadIdentity();
// do some transformations ie scaling
glActiveTextureARB (GL_TEXTURE1_ARB);
glLoadIdentity();
// do some other scalings

might works. But what I don’t remember is how to insert this code when using MultiTexCoord***. Try to put that code before glBegin(…).

It looks like it is skipping the texture matrix ? I am not sure if texture matrix will be considered before texuture mapping or not.[/b]
If you are using vertex shader you have to multiply your tex. coordinates with tex. matrix manualy…

i.e. :
gl_TexCoord[0]=gl_TextureMatrix[0]*gl_MultiTexCoord0;

But the result was not as expected. That may be because I didnt change the texture mapping. I really doubt whether this can be achieved using multitexture at all. But multitexturing is useful for me for combining the two textures based on color value in one of them. But this also means that whatever transformation i do in model view is applied to both the textures. Now my problem is how to apply transformation only to one texture and not another and still get the result as I would have got if I had applied model view transformation. !!!

Sorry for my error (I just know nothing about shaders).

I have another maybe-solution.
You can see textures coordinats as this:

s = scale_factor * real_s + translation
t = scale_factor * real_t + translation

where s and t are the new texture coordinates and real_s and real_t are the old ones (those you specified). With some maths, you can do almost everything you want.

That would work and probably be more efficient, it really depends on the types of transformations you want to support (this is one of the advantages of vertex programs), but it’s worth pointing out that the matrix multiplication posted was nonsense, when you multiply with a matrix you have do more that just multiply by the coordinate by the first row, it’s a full texture coordinate vector transform through the matrix.

And it absolutely can be done with multitexture, you have independent matrices and interpolants (although not necessarily as many as you have texture units you typically have at least 4 fully supported units including matrices and interpolators).

Originally posted by dorbie: but it’s worth pointing out that the matrix multiplication posted was nonsense, when you multiply with a matrix you have do more that just multiply by the coordinate by the first row, it’s a full texture coordinate vector transform through the matrix.

I have to admit that I have never worked with texture matrix in vertex shader but in GLSLSpec is written:
uniform mat4 gl_TextureMatrix[gl_MaxTextureCoords];

so I think that gl_TextureMatrix[0] is not the first row of the tex. matrix but the first texture matrix itself

I am also new to shading language. I am not sure how to make shader affect only one texture and not another.
Today I posted this probem in detail in shading language forum under name “texture transformation and merging”.