#version 330


in vec4 vertex; //vertexposition
in vec2 textureCoords; 

out vec2 fragmentTexCoords;

uniform vec2 CoC;

out vec2 texCoordsLastSlice[20];




void main(void)
{
	fragmentTexCoords = textureCoords;
	gl_Position = vertex;


	fragmentTexCoords.x -= float(fragmentTexCoords.x > 0.5) * CoC.x;
	fragmentTexCoords.x += float(fragmentTexCoords.x < 0.5) * CoC.x;

	fragmentTexCoords.y -= float(fragmentTexCoords.y > 0.5) * CoC.y;
	fragmentTexCoords.y += float(fragmentTexCoords.y < 0.5) * CoC.y;




	//i scale here the last slice(s), 0.33333 because of 1/3
	float xstep = (CoC.x * 0.5) * 0.3333333;
	float ystep = (CoC.y * 0.5) * 0.3333333;



	//x pos y pos
	texCoordsLastSlice[0] = vec2( fragmentTexCoords + vec2( 1.0*xstep , 0.0*ystep ) );
	texCoordsLastSlice[1] = vec2( fragmentTexCoords + vec2( 2.0*xstep , 0.0*ystep ) );

	texCoordsLastSlice[2] = vec2( fragmentTexCoords + vec2( 0.0*xstep , 1.0*ystep ) );
	texCoordsLastSlice[3] = vec2( fragmentTexCoords + vec2( 0.0*xstep , 2.0*ystep ) );

	texCoordsLastSlice[4] = vec2( fragmentTexCoords + vec2( 1.0*xstep , 1.0*ystep ) );
	texCoordsLastSlice[5] = vec2( fragmentTexCoords + vec2( 2.0*xstep , 1.0*ystep ) );
	texCoordsLastSlice[6] = vec2( fragmentTexCoords + vec2( 1.0*xstep , 2.0*ystep ) );

	//x neg y pos
	texCoordsLastSlice[7] = vec2( fragmentTexCoords + vec2( -1.0*xstep , 0.0*ystep ) );
	texCoordsLastSlice[8] = vec2( fragmentTexCoords + vec2( -2.0*xstep , 0.0*ystep ) );


	texCoordsLastSlice[9] = vec2( fragmentTexCoords + vec2( -1.0*xstep , 1.0*ystep ) );
	texCoordsLastSlice[10] = vec2( fragmentTexCoords + vec2( -2.0*xstep , 1.0*ystep ) );
	texCoordsLastSlice[11] = vec2( fragmentTexCoords + vec2( -1.0*xstep , 2.0*ystep ) );


	//x pos y neg
	texCoordsLastSlice[12] = vec2( fragmentTexCoords + vec2( 0.0*xstep , -1.0*ystep ) );
	texCoordsLastSlice[13] = vec2( fragmentTexCoords + vec2( 0.0*xstep , -2.0*ystep ) );

	texCoordsLastSlice[14] = vec2( fragmentTexCoords + vec2( 1.0*xstep , -1.0*ystep ) );
	texCoordsLastSlice[15] = vec2( fragmentTexCoords + vec2( 2.0*xstep , -1.0*ystep ) );
	texCoordsLastSlice[16] = vec2( fragmentTexCoords + vec2( 1.0*xstep , -2.0*ystep ) );


	//x neg y neg
	texCoordsLastSlice[17] = vec2( fragmentTexCoords + vec2( -1.0*xstep , -1.0*ystep ) );
	texCoordsLastSlice[18] = vec2( fragmentTexCoords + vec2( -2.0*xstep , -1.0*ystep ) );
	texCoordsLastSlice[19] = vec2( fragmentTexCoords + vec2( -1.0*xstep , -2.0*ystep ) );



}
