varying vec3 WorldNormal;
varying vec4 projPos;

uniform sampler2D Color1; // ground

uniform sampler2D SceneLight;

void main()
{
  // compute normal for cel-shading like
  vec2 texScene = projPos.xy / projPos.w * .5 + .5;
  vec4 light = texture2D( SceneLight, texScene );

  // scale blending
  vec3 Nscreen = abs( normalize(WorldNormal).xyz ); 
  Nscreen = ( Nscreen - .2 ) * 7.0;
  Nscreen = max( Nscreen, 0.0 );
  Nscreen = Nscreen / ( Nscreen.x + Nscreen.y + Nscreen.z );

  vec3 color = texture2D( Color1, gl_TexCoord[1].zy ).rgb * Nscreen.x +
               texture2D( Color1, gl_TexCoord[1].xz ).rgb * Nscreen.y +
               texture2D( Color1, gl_TexCoord[1].yx ).rgb * Nscreen.z;
  color += vec3(0.111, 0.111, 0.1017);//(0.333, 0.333, 0.305);

  vec3 lightColor = light.rgb + light.a;
  
  color *= lightColor;

  gl_FragColor = vec4( color, 1.0 );
}