#version 150

in vec3 vNormal;
in vec3 vEye;
in vec2 TexCoord;

out vec4 out_Color;

uniform sampler2D TexSampler;

uniform vec3 LightPos;
uniform vec4 SphereColor;

uniform float CurrentTime;
uniform vec2 Resolution;

void main()
{
	
	vec3 n = normalize( vNormal );
	vec3 v = normalize( -vEye );
	vec3 l = normalize( LightPos - vEye );
	vec3 h = normalize( v + l );
	
	float specularCoefficient = 60.0;

	vec2 finalCoord = TexCoord;
	finalCoord.y = 1.0 - finalCoord.y;
	vec4 texColor = texture2D( TexSampler, finalCoord );

	vec3 cAmb = vec3( 0.00, 0.00, 0.0 );
	vec3 cDiff = vec3( SphereColor.xyz );
	vec3 cSpec = vec3( 1.0, 1.0, 1.0 );
	float diff = max( 0.0, dot( n, l ) );//* texColor.a;
	float spec = pow( dot( n, h ), specularCoefficient );
	
	out_Color = vec4( ( cAmb + (cDiff)*diff + cSpec*spec ), SphereColor.w );
}