sampler texture0 : register(s0);
sampler texture1 : register(s1);
				
float4x4 WorldViewProjectionTransform  : WORLDVIEWPROJ;
float fAbsoluteTime;

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;

   // repeat every ten seconds
   float fTiming = ((fAbsoluteTime / 1000.f) % 2) / 2.f;

   float4 color = tex2D(texture0, coord);
   float4 mask = tex2D(texture1, coord);
   
   float fInTime = mask.r;
   float fOutTime = mask.r + 0.03;
   
   float fFactor = step(fInTime, fTiming);
   float fFactor2 = step(fOutTime, fTiming);
   fFactor = fFactor - fFactor2;

   color.a = min(color.a, fFactor);

   return color;
}