varying in vec3 normal,vert;

varying vec2 texCoords;
uniform sampler2D tex0;
uniform float intensity;

void main(void)
{

	vec3 lp=gl_LightSource[0].position.xyz;
	vec3 ld=normalize(lp-vert);
	vec3 ed=normalize(-vert);
	vec3 r=normalize(-reflect(ld,normal));
	
	vec4 la=gl_FrontLightProduct[0].ambient;
	vec4 lf=gl_FrontLightProduct[0].diffuse*max(dot(normal,ld),0.0);
	vec4 ls=gl_FrontLightProduct[0].specular*pow(max(dot(r,ed),0.0),gl_FrontMaterial.shininess);
	
	vec4 pixel = texture2D(tex0, texCoords);
	vec4 light = gl_FrontLightModelProduct.sceneColor+pow(la+lf+ls,0.75);

	gl_FragColor=mix(0,light*intensity,pixel*intensity);
	//gl_FragColor=light;
	
}