#version 150
//precision highp float;
in vec4 vertex_color;
in vec4 vertex_normal;
in vec4 vertex_light_dir;
in vec4 vertex_cam_space;

uniform vec4 light_diffuse;
uniform vec4 material_diffuse;
uniform vec4 light_specular;
uniform vec4 material_specular;
uniform float material_shininess;


out vec4 FragColor;
void main()
{
  vec4 final_color = vec4(0.2, 0.15, 0.15, 1.0); 
  vec4 N = normalize(vertex_normal);
  vec4 L = normalize(vertex_light_dir);
  float lambertTerm = dot(N,L);
  if (lambertTerm > 0.0)
  {
    final_color += light_diffuse * material_diffuse * lambertTerm;	
    vec4 E = normalize(vertex_cam_space);
    vec4 R = reflect(-L, N);
    float specular = pow( max(dot(R, E), 0.0), material_shininess);
    final_color += light_specular * material_specular * specular;	
  }
  FragColor.rgb = final_color.rgb;
  FragColor.a = 1.0;
}
