Add a sea shaded cubes, just because. No big deal (yet).
[mandelwow.git] / shaded.vert
1 #version 300 es
2 precision lowp float;
3
4 in vec3 position;
5 in vec3 normal;
6 out vec4 color;
7
8 uniform mat4 perspective;
9 uniform mat4 view;
10 uniform mat4 model;
11
12 void main() {
13     mat4 modelview = view * model;
14     mat4 m = perspective * modelview;
15     vec3 dark = vec3(0.0, 0.0, 0.1);
16     vec3 bright = vec3(0.0, 0.0, 0.9);
17     vec3 u_light = vec3(-0.5, -0.5, -1.);
18     vec3 v_normal = transpose(inverse(mat3(model))) * normal;
19     float brightness = max(dot(normalize(v_normal), normalize(u_light)), 0.0);
20     color = vec4(mix(dark, bright, brightness), 1.0);
21     gl_Position = m * vec4(position, 1.0);
22 }