#version 330 core
// Input : vertex attributes.
layout (location = 0) in vec3 aPos; // Position of the vertex.
layout (location = 1) in vec3 aNormal; // Normal of the vertex.
layout (location = 2) in vec2 aTexCoords; // Texture coordonate of the vertex.
layout (location = 3) in vec3 aTangent; // Texture coordonate of the vertex.
layout (location = 4) in vec3 aBitangent; // Texture coordonate of the vertex.

// The result : color of the fragment.
out vec3 color;

// Uniform input variable.
uniform mat4 projection; // Projection of the camera.
uniform mat4 model; // Transforms transformation.
uniform mat4 view; // View transformation of the camera.
uniform vec3 lightPos;

void main() {

    gl_Position = projection * view * model * vec4(aPos, 1.0);
    vec4 newPos = model * vec4(aPos, 1.0);
    // vec4 newNormal = model * vec4(aNormal, 1.0);
    vec3 newPos3 = newPos.xyz;
    // vec3 newNormal3 = newNormal.xyz;
    vec3 newNormal3 = mat3(transpose(inverse(model))) * aNormal;
    vec3 lightVec = vec3(normalize((lightPos - newPos3)));
    float diffuse = dot(lightVec, newNormal3);
    //color = vec3(1,1,1);
    color = vec3(diffuse);
}   