/*
	frame 1 algorithm - XPeng
*/

#version 130


uniform sampler2D 	inText;		// input sampler
uniform sampler2D 	frameText0;	// input frame sampler
out     vec4 		outText;	// output sampler

uniform float rangeX, rangeY, rangeW, rangeH;
uniform float preOffsetX, preOffsetY, scaleW, scaleH;

void main()
{
	 vec2 v_texCoord = gl_TexCoord[0].st;
	vec3 col = texture2D(inText, v_texCoord).rgb;

	 vec2 v_texCoordFrame = vec2(v_texCoord.x*rangeW+rangeX, v_texCoord.y*rangeH+rangeY);
	v_texCoordFrame.x = (v_texCoordFrame.x-preOffsetX)/scaleW;
	v_texCoordFrame.y = (v_texCoordFrame.y-preOffsetY)/scaleH;
	
	vec4 colFrame;
	colFrame.abgr = texture2D(frameText0, v_texCoordFrame).rgba; // rgba ==> abgr
	outText = vec4(colFrame.rgb*colFrame.a + col*(1-colFrame.a), 1.0);
}

