#version 400

//layout (location = 0) in vec3 position;

/*
layout (std140) uniform global
{
	vec2 document;

	vec2 other;
};
*/
layout (std140) uniform events
{
	vec2 mouse;

	vec2 window;
};


	//uniform vec2 mouse;

	//uniform vec2 window;



layout(location = 0) in vec3 position;

layout(location = 1) in vec2 textureCoordinates;

layout(location = 2) in int meshIndex;



out vec2 vertex_textureCoordinates;


void main() {

	vec2 mousePosition	= mouse / window;

	mousePosition -= .5;

	mousePosition.y	*= -1.;

	mousePosition *= 2.0;

	gl_Position.xyz = position / vec3(40, 1, 10);

	if( meshIndex == 0 ) {

		gl_Position.xy += mousePosition;

	} else {

		vec2 normalizedPosition	= 1.0 / window;

		normalizedPosition 		-= 0.5;

		normalizedPosition.y	*= -1.;

		normalizedPosition 		*= 2.0;


		normalizedPosition.x 	+= .1;

		normalizedPosition.x 	+= mod( float(meshIndex), 30 )  * ( .08 );

		normalizedPosition.y  	-= 1;

		normalizedPosition.y	-= floor( float(meshIndex) / 30 ) * .5;

		gl_Position.xy += vec2( normalizedPosition );

	}

	//gl_Position.xy /= window;

	vertex_textureCoordinates = textureCoordinates;

	gl_Position.w = 1.0;

}

