float4 main(float2 texCoord: TEXCOORD0,
            float3 normal: TEXCOORD1,
            float4 shadowCoord: TEXCOORD2,

            uniform sampler2D textureMap: TEXUNIT0,
            uniform sampler2D shadowMap: TEXUNIT1,
            uniform float shininess) : COLOR
{
  float3 color0 = float3(0.5, 0.5, 0.54);
  float3 color1 = float3(0.9);
  float3 color2 = float3(0);

  float3 N = normalize(normal);
  float3 L = float3(0, 1, 0);
  float nDotL = dot(N, L);
  float3 diffuse = color0 * clamp(nDotL, 0, 1) + color1 * (1 - abs(nDotL)) + color2 * clamp(-nDotL, 0, 1);
  float3 textureColor = tex2D(textureMap, texCoord).rgb;
  float2 shadowUV = float2(1.0/shadowCoord.w * ((shadowCoord.x + shadowCoord.w) * 0.5),
                           1.0/shadowCoord.w * ((shadowCoord.y + shadowCoord.w) * 0.5));
  float shadow = tex2D(shadowMap, shadowUV).r * 0.5 + 0.5;
  return float4(textureColor * diffuse * shadow, 1.0);
}
