/*
	tint shift algorithm - XPeng
*/

#version 130


uniform sampler2D 	inText;		// input sampler, normal
uniform sampler2D	bluredText;	// input sampler, blured 
out     vec4 		outText;	// output sampler

uniform  float lineA, lineB, lineC;
uniform  float lineRadius1, lineRadius2;
uniform float rangeX, rangeY, rangeW, rangeH;
  
void main()
{
	 vec2 textureCoordinate = gl_TexCoord[0].xy;
     vec4 sharpImageColor = texture2D(inText, textureCoordinate);
     vec4 blurredImageColor = texture2D(bluredText, textureCoordinate);
    
    //distance = (Ax+By+C)/sqrt(A*A+B*B) 
	 vec2 v_texCoord = vec2(gl_TexCoord[0].s*rangeW+rangeX, gl_TexCoord[0].t*rangeH+rangeY);
     float distanceFromLine = (lineA*v_texCoord.x+lineB*v_texCoord.y+lineC)/sqrt(lineA*lineA+lineB*lineB);

	float fFac = clamp((abs(distanceFromLine)-lineRadius1)/(lineRadius2-lineRadius1), 0, 1);
	outText = mix(sharpImageColor, blurredImageColor, fFac);     //slow??
}

