#ifdef GL_ES
precision mediump int;
precision mediump float;
#endif

#define USE_OGRE_FROM_FUTURE
#include <OgreUnifiedShader.h>

SAMPLER2D(LeftTex, 0);
SAMPLER2D(RightTex, 1);

OGRE_UNIFORMS(
uniform vec4 screenSize;
)

MAIN_PARAMETERS
IN(vec2 uv, TEXCOORD0)
MAIN_DECLARATION
{
	vec2 p = step(vec2_splat(0.5), fract(uv * screenSize.xy * vec2_splat(0.5)));
	vec4 left = texture2D(LeftTex, uv);
	vec4 right = texture2D(RightTex, uv);
	
	float f = 0.0;
	if (p.x == p.y)
	  f = 1.0;
	
	// 1-abs(p.x-p.y)
	gl_FragColor = mix(left, right, vec4_splat(f));
}