   Sampler value has not been set in fragment shader ?
  I am having some weird issues with a shader on ATI card HD 4850 (tested with the latest drivers).I am not blaming the driver, I might be doing something wrong.It works fine on Nvidia cards (a couple tested), everything on WinXp.Here is the shader:vec4 getDiffuse(){if( uHasDiffuseMap0 ){if( uHasDiffuseMap1 ){vec4 lD0 = texture2D(uDiffuseMap0, vDiffuse0TexCoord.st);vec4 lD1 = texture2D(uDiffuseMap1, vDiffuse1TexCoord.st);return vec4( lD0.rgb* lD1.rgb, 1.0 );}return vec4( texture2D(uDiffuseMap0, vDiffuse0TexCoord.st).rgb, 1.0);}else if( uHasDiffuseAndOpacityMap0 ){vec4 lD0 = texture2D(uDiffuseAndOpacityMap0, vDiffuse0TexCoord.st);if( uHasDiffuseMap1 ){vec4 lD1 = texture2D(uDiffuseMap1, vDiffuse1TexCoord.st);return vec4( lD0.rgb* lD1.rgb, lD0.a );}return vec4( lD0.rgb, lD0.a );}return vec4(1.0,1.0,1.0,1.0);}void main (void){vec4 lDiffuse = getDiffuse();// Compute final colorvec4 lFinalColor = lDiffuse;gl_FragData[0] = lFinalColor; }Every Uniform (starts with u*) and Varyings (starts with v*) are set. What happens is that either I get a black object when rendered, or sometimes GL_INVALID_OPERATION on the draw call when having multiple objects. The buffers seems to be bound the right, I did intercept the glCalls and everything seems ok.Looking at this post, I have the same warning when validating, although everything is bound. I could use #ifdef stuff, but I want to use dynamic branching. The weirdness seems to come from here:..if( uHasDiffuseAndOpacityMap0 ){vec4 lD0 = texture2D(uDiffuseAndOpacityMap0, vDiffuse0TexCoord.st);}...If I remove the texture fetch, it works, even though the boolean uHasDiffuseAndOpacityMap0 is false and that uDiffuseAndOpacityMap0 is bound 0.The problem seems to come from the shader trying to do a texture fetch when it should not.If I do the following:..if( false ){vec4 lD0 = texture2D(uDiffuseAndOpacityMap0, vDiffuse0TexCoord.st);}...This works, the driver must optimize (luckily) and never go into that branch. Bu then, it seems that with a dynamic, even though the variable is set to false, it does something (a mix ?). With Nvidia cards, with breakpoints in the shader, the program does not enter the if( myvar =false ). I cannot breakpoint with ATI cards, but the uniforms are set like this (coming from GlIntercept)://== PROGRAM LINK STATUS = TRUE//== PROGRAM VALIDATE STATUS = TRUE/*== INFO LOG ==Validation warning! - Sampler value uDiffuseMap1 has not been set in fragment shader Validation successful.   == INFO LOG END ==*///======================================================//  Program uniforms (at render call) //======================================================//  uHasDiffuseAndOpacityMap0  =  0//  uHasDiffuseMap0  =  1//  uHasDiffuseMap1  =  0//  uModelViewMatrix  =  (0.737801,-0.242825,0.629830,0.000000,-0.000000,0.933056,0.359731,0.000000,-0.675019,-0.265409,0.688409,0.000000,0.340252,2.056731,-11.336699,1.000000)//  uProjectionMatrix  =  (3.642313,0.000000,0.000000,0.000000,0.000000,2.414214,0.000000,0.000000,0.000000,0.000000,-1.000040,-1.000000,0.000000,0.000000,-2.000040,0.000000)//  uDiffuseAndOpacityMap0  =  0<TexID = 1>//  uDiffuseMap0  =  0<TexID = 1>//  uDiffuseMap1  =  0<TexID = 1>There is a texture bound to the sampler2Ds (TexID1).Anyone has a clue ? a solution (but the #IF) ?Thanks in advance.   
  I have found my problem. In fact on ATI cards, you cannot bind two sampler 2D on the same texture unit. In my case samplers not used where bound to 0, often the diffuse texture unit, so I did not see the diffuse color... I believe this is a driver bug since the OpenGL spec says it is possible, and it works fine on NVidia cards. This does not remove the validation warning. Hopes this can help someone !   