float4 ambient;
float4 diffuse;
sampler diffuseMap;

float4 main(float3 normal   : TEXCOORD0,
            float3 pos_dir  : TEXCOORD1,
            float2 texCoord : TEXCOORD2,
            float  atten    : TEXCOORD3) : COLOR
{
   float4 d1 = diffuse * (2-diffuse.a) * max(0,dot(normal,pos_dir )) * atten.x;
   return (ambient+d1)*tex2D(diffuseMap,texCoord);
}