// Fragment Shader for phong shading – file "phong.frag"

#version 150 core
uniform vec3 light_position;

in  vec3 ex_normal;
in  vec3 ex_eye;

out vec4 out_color;

void main(void)
{
	float diffuse_intensity;
	float specular_intensity;

	vec3 light;

	vec3 normal;
	vec3 eye;

	vec3 reflection;

	light = normalize(light_position);
	//light = normalize(vec3(5.0, 5.0, 10.0));

	normal = normalize(ex_normal);
	eye = normalize(ex_eye);

	diffuse_intensity = clamp(max( dot(normal, light), 0.0), 0.0, 1.0);

	reflection = normalize(reflect(-light, normal));
	specular_intensity = pow( clamp(max( dot(reflection, eye), 0.0), 0.0, 1.0), 50.0);

	out_color = vec4(0.05, 0.0, 0.0, 1.0) +
				vec4(0.8, 0.0, 0.0, 1.0)*diffuse_intensity
				+ vec4(1.0, 0.9, 0.9, 1.0)*specular_intensity;
}