#version 150 core

uniform mat4 mat_modelview; // eye-space-transform
uniform mat4 mat_projection;
uniform mat4 mat_tex; // light-space-transform

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

out vec2 ex_texcoord;
out vec3 ex_normal;
out vec3 ex_eye;
out vec3 ex_lightdir;
out vec4 ex_SM_tex_coord;

uniform vec3 light_position;

void main(void)
{
    ex_texcoord = in_texcoord;

    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;
    ex_SM_tex_coord = mat_tex * in_position;
}

