   hlsl error: local variables must be numeric
  Hello.I try to make shader whitch just draws 5 textures to plane geometry(some post effect). Corresponding to texel coordinates shader have to indicate whitch texture it have to use to draw upon the geometry. This shader has no vertex shader. So, here is the pixel shader:-------------------------------------------------------float4 PShader( in float2 Tex : TEXCOORD0 ) : COLOR0{    float4 Color = 0;   sampler2D sam;   if (Tex.x < 0) sam = g_samLeft;    else if (Tex.y < 0) sam = g_samTop;    else if (Tex.x > 1) sam = g_samRight;    else if (Tex.x > 1) sam = g_samBottom;    else sam = g_samSrc;    for (int i = 0; i < 16; i++)    {   Color += tex2D( sam, Tex + TexelCoordsDownFilter.xy );    }    return Color / 16;}-------------------------------------------------------The problem is that shader compiles with error: "local variables must be numeric". I tryed to make pixel shader that it has 5 for statements (One for evere if), but there was another error: program too large.Could anyone help me??
  The first problem is caused by:sampler2D sam;;Quote:Original post by user88Hello.I try to make shader whitch just draws 5 textures to plane geometry(some post effect). Corresponding to texel coordinates shader have to indicate whitch texture it have to use to draw upon the geometry. This shader has no vertex shader. So, here is the pixel shader:-------------------------------------------------------float4 PShader( in float2 Tex : TEXCOORD0 ) : COLOR0{    float4 Color = 0;sampler2D sam;if (Tex.x < 0) sam = g_samLeft;    else if (Tex.y < 0) sam = g_samTop;    else if (Tex.x > 1) sam = g_samRight;    else if (Tex.x > 1) sam = g_samBottom;    else sam = g_samSrc;    for (int i = 0; i < 16; i++)    {   Color += tex2D( sam, Tex + TexelCoordsDownFilter.xy );    }    return Color / 16;}-------------------------------------------------------The problem is that shader compiles with error: "local variables must be numeric". I tryed to make pixel shader that it has 5 for statements (One for evere if), but there was another error: program too large.Could anyone help me??Samplers must be created as costants and not as variables.   ;  thanks for replays. i thinked that sampler2d can be simlpe local varible ((   