#version 400

out vec4 FragColor;

in vec3 Position;
in vec2 TexCoord;
in vec3 Normal;

uniform sampler2D diffuse;

uniform vec3 viewPosition;

uniform vec3 phongAmbient;
uniform vec3 phongDiffuse;
uniform vec3 phongSpecular;
uniform float phongShininess;

uniform vec3 lightDirection;
uniform vec3 lightAmbient;
uniform vec3 lightDiffuse;
uniform vec3 lightSpecular;

void main() {
    vec4 diffuseColor = texture(diffuse, TexCoord);

    vec3 norm = normalize(Normal);
    vec3 lightDir = normalize(-lightDirection);

    vec3 ambient = phongAmbient * vec3(diffuseColor);

    float diffImpact = max(dot(norm, lightDir), 0.0);
    vec3 diffuse = (phongDiffuse * vec3(diffuseColor)) * diffImpact;

    vec3 result = ambient + diffuse;
    FragColor = vec4(result, 1.0);
}