#version 330

in vec4 vertex_color;
in vec2 texture_coord;
in vec3 normal;

out vec4 color;

struct Directional_Light {
    vec3 color;
    float ambient_intensity;
    vec3 direction;
    float diffuse_intensity;
};

uniform sampler2D tex;
uniform Directional_Light sun;

void main() {
    vec4 ambient_color = vec4(sun.color, 1.0f) * sun.ambient_intensity;

    float diffuse_factor = max(dot(normalize(normal), normalize(sun.direction)), 0.0f);
    vec4 diffuse_color = vec4(sun.color, 1.0f) * sun.diffuse_intensity * diffuse_factor;

    color = texture(tex, texture_coord) * (ambient_color + diffuse_color);
}
