#version 330

in vec2 fragTexCoord; // texture coordinate
in vec3 fragNormal;   // normal direction

uniform sampler2D texture0;
uniform vec4 colDiffuse;

out vec4 finalColor;

uniform vec3 lightDirection; // direction of light
uniform vec4 ambient;

void main() {
    vec4 texelColor = texture(texture0, fragTexCoord);
    vec3 light_dot = vec3(pow(clamp(dot(fragNormal, lightDirection), 0.0, 1.0), 2.0));
    finalColor = texelColor * colDiffuse * vec4(light_dot, 1.0);
    finalColor += texelColor * (ambient/10.0) * colDiffuse;
    finalColor = pow(finalColor, vec4(vec3(0.6), 1.0));
}
