1attribute vec3 position;
2attribute vec3 normal;
3attribute vec2 texcoord;
4
5uniform mat4 ModelViewProjectionMatrix;
6uniform mat4 NormalMatrix;
7
8varying vec4 Color;
9varying vec2 TextureCoord;
10
11void main(void)
12{
13    // Transform the normal to eye coordinates
14    vec3 N = normalize(vec3(NormalMatrix * vec4(normal, 1.0)));
15
16    // The LightSourcePosition is actually its direction for directional light
17    vec3 L = normalize(LightSourcePosition.xyz);
18
19    // Multiply the diffuse value by the vertex color (which is fixed in this case)
20    // to get the actual color that we will use to draw this vertex with
21    float diffuse = max(dot(N, L), 0.0);
22    Color = vec4(diffuse * MaterialDiffuse.rgb, MaterialDiffuse.a);
23
24    // Set the texture coordinates as a varying
25    TextureCoord = texcoord;
26
27    // Transform the position to clip coordinates
28    gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0);
29}
30