   GLSL texture splatting with several textures and just one texture coordinate system.
  I'm working in a terrain renderer/editor for a game. Well I'm using shaders and I have several textures (2 RGBA textures with the masks + 8 ground textures) to blend in a chunk. But I just need a texture coordinate system because all the textures will have te same size without <<offsets?>> (Well, English isn't my native language, sorry).// We can blend 6 ground texturesuniform int NumTextures;// We have 2 textures, with 4 masks (RGBA) eachoneuniform sampler2D Mask1;uniform sampler2D Mask2;// There are to textures for the traks, one of sand and another one of stoneuniform sampler2D Path1;uniform sampler2D Path2;// We have to link the textures with the shadders beforeuniform sampler2D Ground1;uniform sampler2D Ground2;uniform sampler2D Ground3;uniform sampler2D Ground4;uniform sampler2D Ground5;uniform sampler2D Ground6;// Get the masksvec4 mask1 = texture2D(Mask1, gl_TexCoord[0].xy);vec4 mask2 = texture2D(Mask2, gl_TexCoord[0].xy);// Get the path texturesvec4 path1 = texture2D(Path1, gl_TexCoord[0].xy);vec4 path2 = texture2D(Path2, gl_TexCoord[0].xy);// Get the ground texturesvec4 ground1 = texture2D(Ground1, gl_TexCoord[0].xy);vec4 ground2 = texture2D(Ground2, gl_TexCoord[0].xy);vec4 ground3 = texture2D(Ground3, gl_TexCoord[0].xy);vec4 ground4 = texture2D(Ground4, gl_TexCoord[0].xy);vec4 ground5 = texture2D(Ground5, gl_TexCoord[0].xy);vec4 ground6 = texture2D(Ground6, gl_TexCoord[0].xy);void main(){    // Sets the first ground    vec4 out_color = ground1;// Iterate and blend textures with the pathsfor(int idx=1;idx<NumTextures;idx++){   if(idx==1)   {  out_color = out_color * mask1.r;  out_color = mix(out_color, ground2, mask1.g);   }   else if(idx==2)  out_color = mix(out_color, ground3, mask1.b);   else if(idx==3)  out_color = mix(out_color, ground4, mask1.a);   else if(idx==4)  out_color = mix(out_color, ground5, mask2.r);   else if(idx==5)  out_color = mix(out_color, ground6, mask2.g);}// Blend pathsout_color = mix(out_color, path1, mask2.b);out_color = mix(out_color, path2, mask2.a);gl_FragColor = out_color;}