#ifdef GL_ES
// Set default precision to medium
precision mediump int;
precision mediump float;
#endif

uniform mat4 m_matrix;
uniform mat4 mv_matrix;
uniform mat4 mvp_matrix;

attribute vec3 a_position;
attribute vec3 a_normal;
attribute vec2 a_texcoord;
attribute vec3 a_tangent;
attribute vec3 a_color;

varying vec3 v_WorldPos;
varying vec3 v_CamPos;

varying vec3 v_normal;
varying vec2 v_texcoord;
varying mat3 normalMat;

varying vec3 v_color;

void main() {



	// interpolation:
	v_WorldPos = vec3(m_matrix * vec4(a_position, 1.0));
	v_CamPos = vec3(mv_matrix * vec4(a_position, 1.0));
	v_normal = a_normal;//normalize(vec3(mv_matrix * vec4(a_normal, 0.0)));
	v_texcoord = a_texcoord;
	v_color = a_color;


	// http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-13-normal-mapping/
	vec3 bitangent = cross(a_normal, a_tangent);
	normalMat = mat3(a_tangent, bitangent, a_normal);

	// 2D position for the vertex
	gl_Position = mvp_matrix * vec4(a_position, 1.0);

}
