varying vec3 vNormal;
varying vec4 vVertex;

void main(void)
{
	vec3 vN = normalize(vNormal);
	
	vec3 L0 = normalize(gl_LightSource[0].position.xyz - vVertex.xyz); 
	vec3 L1 = normalize(gl_LightSource[1].position.xyz - vVertex.xyz); 
	vec3 E = -normalize(vVertex.xyz); // we are in Eye Coordinates, so EyePos is (0,0,0)
	vec3 R0 = -normalize(reflect(L0,vN)); 
	vec3 R1 = -normalize(reflect(L1,vN)); 

	vec4 Iamb = (gl_LightSource[0].ambient + gl_LightSource[1].ambient) * gl_FrontMaterial.ambient;
	vec4 Idiff0 = gl_LightSource[0].diffuse * gl_FrontMaterial.diffuse * max(dot(vN,L0), 0.0);
	vec4 Idiff1 = gl_LightSource[1].diffuse * gl_FrontMaterial.diffuse * max(dot(vN,L1), 0.0);
	vec4 Ispec0 = gl_LightSource[0].specular * gl_FrontMaterial.specular * pow(max(dot(R0,E),0.0),gl_FrontMaterial.shininess);
	vec4 Ispec1 = gl_LightSource[1].specular * gl_FrontMaterial.specular * pow(max(dot(R1,E),0.0),gl_FrontMaterial.shininess);

	gl_FragColor = gl_FrontLightModelProduct.sceneColor + Iamb + Idiff0 + Idiff1 + Ispec0 + Ispec1; 
}
