28 lines
565 B
GLSL
28 lines
565 B
GLSL
#version 330 core
|
|
|
|
in vec3 frag_position;
|
|
in vec3 frag_normal;
|
|
|
|
uniform vec3 u_color = vec3(1,1,1);
|
|
uniform vec3 u_light_direction = vec3(1, 3, 2);
|
|
|
|
out vec4 FragColor;
|
|
|
|
void main()
|
|
{
|
|
|
|
// Face normal
|
|
vec3 normal = normalize(frag_normal);
|
|
// Directional lighting
|
|
vec3 light_direction = normalize(u_light_direction);
|
|
|
|
float diffuse = max(dot(normal, light_direction), 0.0);
|
|
|
|
// Ambient + diffuse
|
|
float ambient = 0.25;
|
|
float lighting = ambient + diffuse * 0.75;
|
|
|
|
vec3 color = u_color * lighting;
|
|
|
|
FragColor = vec4(color, 1.0);
|
|
} |