#ifdef GL_ES
precision mediump float;
#endif

varying vec4 v_fragmentColor;
varying vec2 v_texCoord;

uniform sampler2D SamplerBGRA;
uniform sampler2D SamplerTableTex1;
uniform sampler2D SamplerTableTex2;
uniform sampler2D SamplerBackTex1;
uniform sampler2D SamplerBackTex2;

uniform mediump float kk;
uniform mediump float which;

void main(void)
{
    mediump vec3 dst;
    mediump vec3 dst_a;
    mediump vec3 txt;
    
    mediump float offset;
    mediump vec2  coord;
    
    dst.rgb = texture2D(SamplerBGRA, v_texCoord).bgr;
    //if which == 0 else ...
    offset = (1.0 - kk)*0.5;
    coord = vec2(offset*(1.0-which)+v_texCoord.x*(which+(1.0-which)*kk), offset*which + v_texCoord.y*(1.0-which+which*kk));
    txt = texture2D(SamplerBackTex1, coord).rgb;
    
    dst_a =dst*0.7 +txt*0.3;
    gl_FragColor = vec4(dst_a,1.0);
}