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