varying vec2 tex_coord;
varying vec2 pix_coord;

#if defined(VERTEX)

void main()
{
	pix_coord = vec2(gl_MultiTexCoord0.x, 1.0-gl_MultiTexCoord0.y)*1.0001;
	tex_coord = vec2((gl_Vertex.x+1.0)*0.5, (-gl_Vertex.y+1.0)*0.5);
	vec4 pos = vec4(gl_Vertex.x * 2.0, gl_Vertex.y * 2.0, gl_Vertex.z, gl_Vertex.w);
	gl_Position = gl_Vertex; //(gl_Vertex*2)-vec3(1.0, 1.0, 1.0);//gl_ModelViewProjectionMatrix * gl_Vertex;
}

#elif defined(FRAGMENT)

uniform sampler2D Texture;

void main()
{
	float x = sign(pix_coord.x)*floor(abs(pix_coord.x)+0.5);
	float column = mod(x,4.0);
	vec4 color = texture2D(Texture, tex_coord);
	float xfade = abs((tex_coord.s * 2.0) - 1.0);
	xfade = xfade * xfade * xfade * xfade * xfade;
	float yfade = abs((tex_coord.t * 2.0) - 1.0);
	yfade = yfade * yfade * yfade * yfade * yfade;
	color = color + vec4(0.7, 0.7, 0.7, 0.0) * (1.0-tex_coord.t) * (1.0-xfade) * (1.0-yfade);
	vec4 newcolor;
	if (column == 0.0) {
		newcolor = color * vec4(1.0, 0.4, 0.6, 1.0);
	} else if (column == 1.0) {
		newcolor = color * vec4(0.4, 1.0, 0.4, 1.0);
	} else if (column == 2.0) {
		newcolor = color * vec4(0.6, 0.4, 1.0, 1.0);
	} else {
		newcolor = color * vec4(0.2, 0.2, 0.2, 1.0);
	}
	gl_FragColor = newcolor;
}

#endif
