varying vec3 ViewPos;
varying vec3 taneye;
varying vec3 up;
varying vec4 projPos;

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

uniform sampler2D SceneLight;
uniform sampler2D SceneNormal;
uniform sampler2D SceneColor;

const float scale = 0.2;

uniform float Timer;

void main()
{
  vec2 texCoords = gl_TexCoord[0].st;
  float SPEED = 1.0 / 512.0; // ?
  texCoords.y -= Timer * SPEED;

  vec3 norm = texture2D( Normal, texCoords ).rgb;
  
  float light = 0.5 * norm.g;//dot( norm, vec3( 0.0, 1.0, 0.0 ) );

  vec2 texScene = projPos.xy / projPos.w * .5 + .5;

  vec4 scene = texture2D( SceneColor, texScene );
  
  vec3 color = vec3(0.2, 0.2, 0.4) * (scene.rgb + light*light*light*light); // For now
  color += vec3( 0.0, 0.1, 0.03 );

  color += 0.5;
  color *= color;
  color *= 0.5;
  //color = min( color, vec3( 0.7569, 0.8902, 0.9922 ) );

  gl_FragColor = vec4( color, light );
}