uniform mat4 u_MVPMatrix;     // A constant representing the combined model/view/projection matrix.
uniform mat4 u_MVMatrix;      // A constant representing the combined model/view matrix.
uniform vec3 u_LightPos;      // The position of the light in eye space.

attribute vec4 a_Position;    // Per-vertex position information we will pass in.
attribute vec3 a_Normal;      // Per-vertex normal information we will pass in.
attribute vec2 a_TexCoordinate;     // Per-vertex texture coordinate information we will pass in.

varying float v_diffuse;         // This will be passed into the fragment shader.
varying vec2 v_TexCoordinate;       // This will be passed into the fragment shader.

// The entry point for our vertex shader.
void main()
{
    /* OLD */
    vec3 position = vec3(u_MVMatrix * a_Position);
    vec3 lightVector = normalize(/*u_LightPos*/ - position);
    vec3 normal = normalize(mat3(u_MVMatrix) * a_Normal); // maybe better cut matrix?

    v_diffuse = max(dot(normal, lightVector), 0.2);
    v_TexCoordinate = a_TexCoordinate;

    gl_Position = u_MVPMatrix * a_Position;


    /* OTHER
    vec3 newNormal = modelViewProjMatrix * normal;
    vec4 newPosition = modelViewProjMatrix * position;
    gl_Position = newPosition;

    lightIntensity = max(0.0, dot(newNormal.xyz, lightDirection));
    */

    /*
    vec3 normal = vec3(u_MVMatrix * vec4(a_Normal, 0.0));
    vec3 lightVector = normalize(u_LightPos - a_Position.xyz);

    v_diffuse = max(dot(normal, lightVector), 0.2);
    v_TexCoordinate = a_TexCoordinate;

    gl_Position = u_MVPMatrix * a_Position;
    */
}