2023-10-15 18:38:47 +00:00
|
|
|
#version 330 core
|
|
|
|
in vec4 frag_pos;
|
|
|
|
in vec4 frag_normal;
|
2023-10-21 11:08:30 +00:00
|
|
|
in vec3 object_color;
|
2023-10-16 18:48:12 +00:00
|
|
|
|
2023-10-15 18:38:47 +00:00
|
|
|
out vec4 output;
|
|
|
|
|
|
|
|
void main() {
|
2023-10-21 11:08:30 +00:00
|
|
|
vec4 norm = normalize(frag_normal);
|
2023-10-22 11:40:22 +00:00
|
|
|
vec4 ambient = vec4(0.7, 0.7788, 0.46, 1.0);
|
2023-10-21 11:08:30 +00:00
|
|
|
vec4 light_color = vec4(0.7, 0.7, 0.7, 1.0);
|
|
|
|
vec4 color = vec4(object_color.xyz, 1.0f);
|
2023-10-15 18:38:47 +00:00
|
|
|
|
2023-11-10 22:27:20 +00:00
|
|
|
vec4 light_location = vec4(0.0, 100.0, 0.0, 1.0);
|
2023-10-21 11:08:30 +00:00
|
|
|
vec4 light_direction = normalize(light_location - frag_pos);
|
|
|
|
float diff = max(dot(norm.xyz, light_direction.xyz), 0.0);
|
2023-10-15 18:38:47 +00:00
|
|
|
|
2023-10-21 11:08:30 +00:00
|
|
|
vec4 diffuse = diff * light_color;
|
|
|
|
|
2023-11-10 22:27:20 +00:00
|
|
|
output = color + diffuse;
|
2023-11-10 18:42:17 +00:00
|
|
|
}
|