#version 150 core

uniform mat4 mat_modelview;
uniform mat4 mat_projection;

in vec4 in_position;
in vec3 in_normal;
in vec4 in_tangent;
in vec2 in_texcoord;

out vec3 ex_normal;
out vec3 ex_tangent;
out vec3 ex_bitangent;
out vec2 ex_texcoord;
out vec3 ex_eye;
out vec3 ex_lightdir;

uniform mat4 mat_camera;
uniform vec3 light_position;

void main(void)
{
    ex_texcoord = in_texcoord;
    ex_tangent = vec3(in_tangent);
    ex_bitangent = cross(in_normal, in_tangent.xyz) * in_tangent.w;

    mat3 NormalMatrix = transpose(inverse(mat3(mat_modelview)));
    ex_normal = NormalMatrix * in_normal;

    vec3 vVertex = vec3(mat_modelview * in_position);
    ex_eye = -vVertex;
    ex_lightdir = vec3(-light_position - vVertex);

    gl_Position = mat_projection * mat_modelview * in_position;
}

