float4x4 matAll;
float FogStart;
float FogEnd;


float move;
float Ampli;

struct VS_INPUT
{
  	float4 position  : POSITION;
   	float2 tex0 : TEXCOORD0;
};

struct VS_OUTPUT
{
     	float4 position: POSITION;
   	float2 tex0 : 	 TEXCOORD0;
  	float fog: TEXCOORD1;
};

VS_OUTPUT main( VS_INPUT IN )
{

    int bird=round(IN.tex0.y+0.5f);

	move+=bird*5;
	move=cos(move)*4.3f;
	float tx=IN.tex0.x;
	if (tx<0.35f) {IN.position.y+=(0.37f-tx)*move;}
	float sia=sin(Ampli+bird*5);
	IN.position.y-=move*0.1f+sia*2;
	IN.position.x+=sia*3;

   VS_OUTPUT OUT;
   OUT.position = mul( IN.position, matAll );
   OUT.tex0 = IN.tex0;

	float fogy=(OUT.position.z-FogStart)/(FogEnd-FogStart);
        if (fogy>1) {fogy=1;}
        if (fogy<0) {fogy=0;}
        OUT.fog=fogy;

     return OUT;
}