/* COMPATIBILITY 
   - HLSL compilers
   - Cg   compilers
*/

struct input
{
   float2 video_size;
   float2 texture_size;
   float2 output_size;
   float frame_count;
   float frame_direction;
   float frame_rotation;
};

void main_vertex
(
   float4 position : POSITION,
   out float4 oPosition : POSITION,
   uniform float4x4 modelViewProj,

   float4 color : COLOR,
   out float4 oColor : COLOR,

   float2 tex : TEXCOORD,
   out float2 oTex : TEXCOORD
)
{
   oPosition = mul(modelViewProj, position);
   oColor = color;
   oTex = tex;
}

float seed_random (float2 coords, float frame_cnt)
{
   frame_cnt = cos(frame_cnt);
   float2 constant1 = frame_cnt * float2(142.0/11.0, 1017.0/13.0);
   float constant2 = frame_cnt * 481344.0 / 11.0;
   return saturate(frac(sin(dot(coords, constant1)) * constant2) + 0.2);
}

float4 main_fragment (float2 tex : TEXCOORD, uniform sampler2D s0 : TEXUNIT0, uniform input IN) : COLOR
{
   float2 texelSize = 1.0 / IN.texture_size;
   float rand = seed_random(tex, IN.frame_count);
   float4 color = tex2D(s0, tex.xy);
   color = (color - 16.0/255.0) * (255.0/219.0);
   return color * rand;
}


