sampler texture0 : register(s0);
				
float4x4 WorldViewProjectionTransform  : WORLDVIEWPROJ;
float2 fTextureSize;
float fAbsoluteTime;
float fRandom;
float fVignettingFactor;

struct VS_OUTPUT 
{
   float4 Position   : POSITION0;
   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;
}

float4 pixelMain(VS_OUTPUT In) : COLOR0
{
   float2 coord = In.TexCoord;

   float4 px1 = tex2D(texture0, coord);

   float fContrast = 0.7f;

   // get distance to center for vignetting
   float2 centerDist = In.TexCoord - 0.5f;
   float fDistance = dot(centerDist, centerDist);
   px1 = saturate(px1 * fContrast + 0.125f);
   px1 *= 1.f - (fDistance * fVignettingFactor);

   float fGreyValue = dot(px1, float4(0.299f, 0.587f, 0.114f, 0.f));
   fGreyValue *= 0.9f + 0.3f * fRandom + 0.3f * (1.f + sin(fAbsoluteTime/200.f) / 2.f);
   fGreyValue = saturate(fGreyValue);

   return float4(fGreyValue * float3(0.9f, 0.8f, 0.6f), 1.f);
}