varying vec3 taneye;
varying vec4 projPos;

uniform sampler2D Color1; // ground
uniform sampler2D Normal; // normal map with bump!

uniform sampler2D SceneLight;
uniform vec3 LightHue;

const float scale = 4.0;

void main()
{
  vec2 texScene = projPos.xy / projPos.w * .5 + .5;

  // compute normal for cel-shading like
  vec4 light = texture2D( SceneLight, texScene );

    // parallax bump
  float height = scale * texture2D( Normal, gl_TexCoord[0].st ).r;

  // offset texture look up
  vec2 texCoord = gl_TexCoord[0].st + height * taneye.xy;

  // color is offset
  vec3 color = texture2D( Color1, texCoord ).rgb;
  color += (0.2 * scale) * LightHue;
  vec3 lightColor = light.rgb + light.a;// * (( 1.0 - p ) * light.rgb + vec3( p, p, p ));
  
  color *= lightColor;

  float blend = gl_TexCoord[0].t * 2.2 - 1.1;
  blend = smoothstep(0.0, 0.8, abs(blend));

  color = mix(color, 0.25 * LightHue, blend);

  gl_FragColor = vec4( color, 1.0 );
}