#version 330

in vec2 fragTexCoord;
in vec4 fragColor;
in vec3 fragNormal;

uniform sampler2D texture0;
uniform vec4 colDiffuse;

out vec4 finalColor;

void main() {
    vec4 texel = texture(texture0, fragTexCoord) * colDiffuse * fragColor;

    vec3 normal = normalize(fragNormal);
    vec3 lightDir = normalize(vec3(-0.5, 1.0, -0.5));

    float diffuse = max(dot(normal, lightDir), 0.0);
    float shade = min(diffuse + 0.15, 1.0);

    finalColor = vec4(texel.rgb * shade, texel.a);
}