float4x4 matAll;
float4x4 matWorld;
float3 LightDir;
float FogStart;
float FogEnd;

struct VS_INPUT
{
  float4 position: POSITION;
  float2 texCoord0: TEXCOORD0;
  float3 normal: NORMAL;
};

struct VS_OUTPUT
{
  float4 position: POSITION;
  float2 texCoord0: TEXCOORD0;
  float3 light: TEXCOORD1;
  float fog: TEXCOORD2;
};

VS_OUTPUT main( VS_INPUT IN )
{
   VS_OUTPUT OUT;
     OUT.position = mul( IN.position, matAll );
     OUT.texCoord0 = IN.texCoord0;
     float li=dot(normalize(mul(IN.normal,matWorld)),normalize(LightDir));
     if (li<0) {li=0;}
     OUT.light = li;
        float fogy=(OUT.position.z-FogStart)/(FogEnd-FogStart);
        if (fogy>1) {fogy=1;}
        if (fogy<0) {fogy=0;}
        OUT.fog=fogy;
   return OUT;
}
