sampler texture0 : register(s0);

float4x4 WorldViewProjectionTransform  : WORLDVIEWPROJ;
float2 fTextureSize;
float redFactor;
float greenFactor;
float blueFactor;

struct VS_OUTPUT 
{
   float4 Position  : POSITION;
   float2 TexCoord  : TEXCOORD0;    
};

VS_OUTPUT vertexMain(
				float4 vPosition : POSITION,
				float2 texCoord0 : TEXCOORD0)
{
   VS_OUTPUT Output; 
   
   Output.Position = mul(vPosition, WorldViewProjectionTransform);
   Output.TexCoord = texCoord0;   

   return Output;
}

struct PS_OUTPUT
{
    float4 RGBColor : COLOR0;  // Pixel color    
};

PS_OUTPUT pixelMain(VS_OUTPUT In)
{
   PS_OUTPUT result;
   float2 incoord = In.TexCoord + 1.f / fTextureSize / 2.f; 
   float4 color = tex2D(texture0, incoord);
   float fGrey = 0.3 * color.r + 0.59 * color.g + 0.11 * color.b;
   result.RGBColor.a = color.a;
   result.RGBColor.r = saturate(fGrey * redFactor);
   result.RGBColor.g = saturate(fGrey * greenFactor);
   result.RGBColor.b = saturate(fGrey * blueFactor);  
   return result;
}