
uniform sampler2D baseMap;
uniform sampler2D currentMap;

varying vec2 Texcoord;

uniform float uvx1;
uniform float uvxex;
uniform float uvy1;
uniform float uvyex;

void main(void)
{
	vec2 UV = Texcoord;
	UV.y = 1.0 - UV.y;

	vec4 new = texture2D(baseMap, UV);
	
	
	vec2 currentUV;
	currentUV.x = uvx1 + UV.x * uvxex;
	currentUV.y = 1.0 - (uvy1 + (UV.y) * uvyex);
	
	vec4 current = texture2D(currentMap, currentUV);
	
	float newB = new.x + new.y + new.z;
	float currentB = current.x + current.y + current.z;
	
	if (newB > currentB)
		gl_FragColor = new;
	else
		gl_FragColor = current;
		
	//gl_FragColor = clamp(new + current, vec4(0,0,0,0), vec4(1,1,1,1));
}