#version 400

uniform mat4 view; 
uniform float lightIntensity;

in vec4 esNormal;
in vec4 esPosition;
in vec4 matlColor;

out vec4 result;

const vec3 wslightPos = vec3( 2.13, 5.487, 2.27 );
const vec3 lightColor = vec3( 1.0, 0.85, 0.43); //vec3( 18.4, 15.6, 8.0 );

// This is the actual code that is executed.
void main( void )
{
	vec4 esLightPos = view * vec4( wslightPos, 1.0 );

    vec3 esNorm  =  normalize(esNormal.xyz);
	vec3 toEye   = -normalize(esPosition.xyz);
	vec3 toLight =  normalize(esLightPos.xyz-esPosition.xyz);
	
	float NdotL  =  clamp(dot(toLight,esNorm),0,1);
	
	result = vec4( NdotL * lightIntensity * lightColor * matlColor.xyz, 1.0 );
}