--- /dev/null
+#version 330 core
+
+in vec3 view_position;
+in vec3 view_normal;
+
+struct DirectionalLight {
+ // direction in view space
+ vec3 direction;
+ vec3 ambient;
+ vec3 diffuse;
+ vec3 specular;
+};
+uniform DirectionalLight global_light = DirectionalLight(
+ vec3(0.57735026918962576451),
+ vec3(0.1),
+ vec3(1.0),
+ vec3(1.0)
+);
+
+
+void main() {
+ // TODO: pull from texture (or some other source)
+ const vec3 material_color = vec3(1.0);
+
+ vec3 normal = normalize(view_normal);
+ float cos_theta = dot(normal, global_light.direction);
+ float cos_alpha = dot(-normalize(view_position), reflect(-global_light.direction, normal));
+
+ vec3 ambient = global_light.ambient * material_color;
+ vec3 diffuse = global_light.diffuse * material_color * max(0.0, cos_theta);
+ vec3 specular = global_light.specular * pow(max(0.0, cos_alpha), 5);
+
+ gl_FragColor = vec4(ambient + diffuse + specular, 1.0);
+}
--- /dev/null
+#version 330 core
+
+layout(location = 0) in vec3 vert_position;
+layout(location = 1) in vec3 vert_normal;
+
+uniform mat4 MV;
+uniform mat4 MVP;
+
+out vec3 view_position;
+out vec3 view_normal;
+
+void main() {
+ gl_Position = MVP * vec4(vert_position, 1.0);
+ view_position = (MV * vec4(vert_position, 1.0)).xyz;
+ view_normal = mat3(MV) * vert_normal;
+}