uniform sampler2D texture;
uniform bool useOnlyTexture;

varying vec4 position;
varying vec3 normal;

void main()
{	
	vec3 lightVec1 = gl_LightSource[0].position.xyz + vec3(5, 6, -10) - position.xyz;
	vec3 lightVec2 = gl_LightSource[0].position.xyz + vec3(-5, 6, 10) - position.xyz;
	lightVec1 = normalize(lightVec1);
	lightVec2 = normalize(lightVec2);
	float cosAlpha = max(0.0, dot(normal, lightVec2));

   vec3 R = normalize(reflect(-lightVec1, normal));
   float cosTheta = max(0.0, dot(R, normalize(-position.xyz)));

	gl_FragColor = texture2D(texture, gl_TexCoord[0].st);
   
   if(!useOnlyTexture)
   {
      gl_FragColor *= vec4(0.9) * (cosAlpha);
      gl_FragColor += vec4(0.85, 0.8, 0.7, 0)*pow(cosTheta, 12.0) + gl_FrontMaterial.diffuse/4.0;
   }
   gl_FragColor.a = 0.0;
}