uniform lowp sampler2D g_Texture;
uniform lowp vec4 g_Color;

uniform lowp int effectGet;
uniform lowp int checkvertical;
uniform lowp vec4 colormul;
uniform lowp vec4 charpos;


varying highp vec2 texCoord;
varying lowp vec2 position;


void main()
{
	lowp vec4 colorGet = texture2D(g_Texture, texCoord) ;
	
	
	if (colorGet.a<=0.0) discard;
	
	if (effectGet != 0){
		if ((effectGet == 1) && (checkvertical <= 1)){
			if  ((abs(position.x - charpos.x) >= 210) || ((position.y - charpos.y)  >= 285) || ((position.y - charpos.y)  <= 40))    discard;
		}
		
		lowp vec2 adder = vec2(0.0, 0.5) ;
		if (checkvertical == 1){
			if(texCoord.x >= 0.5) discard;
			adder = vec2(0.5, 0.0) ;
		}else if (checkvertical == 2){
			if(texCoord.y <= 0.5) discard;
			adder = vec2(0.0, -0.5) ;
		}else{
			if(texCoord.y >= 0.5) discard;
		}
		
		lowp vec4 normal = texture2D(g_Texture, texCoord + adder ) * 2.0 - 1.0;

		if (normal.b > -0.3){
			lowp vec3 nmz = normalize(vec3(  charpos.xy - position.xy , 0 ));
			// nmz.x = nmz.x * 1.25;
			
			lowp float diff = distance( vec3(normal.r  ,normal.g , 0),nmz) ;
			diff = (1-diff);
			
			
			if (diff > 0.001){
				colorGet.rgb += colorGet.rgb * diff * 1.5;
			}else{
				colorGet.rgb += colorGet.rgb * diff * 0.2;
			}
		}
	}
		
	
	if(colormul.r != -1 ){
		colorGet *= colormul;
	}
	
	gl_FragColor = colorGet;
}
