// Vertex Shader for experiments – file "texture_shadowmap.vert"
//

#version 330 core

uniform mat4 perspective_matrix;
uniform mat4 modelview_matrix;
uniform mat4 model_matrix;
uniform mat4 lightview_matrix;

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

out vec4 ex_lightspace_position;
out vec3 ex_normal;
out vec3 ex_eye;
out vec2 fragment_texcoord;
//odsm
out vec4 worldspace_pos;

void main(void)
{
	fragment_texcoord = in_texcoord;

	ex_normal = (modelview_matrix * vec4(in_normal, 0.0)).xyz;

	//TODO: optimize matrix multiplications
	worldspace_pos = model_matrix * in_position;
	ex_eye = (modelview_matrix * in_position).xyz;
	ex_eye = -normalize(ex_eye);

	ex_lightspace_position = lightview_matrix * in_position;

	gl_Position = perspective_matrix * modelview_matrix * in_position;
}
