#version 400 core

in vec2 pass_textureCoords;
in vec3 surfaceNormal;
in vec3 toLightVector;

out vec4 outColor;

uniform sampler2D textureSampler;
uniform vec3 lightColor;

uniform bool isHighlighted;

void main(void) {
    vec3 unitNormal = normalize(surfaceNormal);
    vec3 unitToLightDir = normalize(toLightVector);

    float cosTheta = dot(unitNormal, unitToLightDir);
    float brightness = max(cosTheta, 0.2);
    vec3 diffuse = brightness * lightColor;

    if(isHighlighted) {
        outColor = vec4(1.0f, 1.0f, 0.0f, 1.0f);
    } else {
        outColor = vec4(diffuse, 1.0f) * texture(textureSampler, pass_textureCoords);
    }

}