
#version 130


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

out     vec4 		outText;	// output sampler

void main(void)
{
	vec2 v_texCoord = gl_TexCoord[0].st;        

     vec3 dst;
    dst.rgb = texture2D(SamplerBGRA, v_texCoord).rgb;

    //1
    dst.r = texture2D(SamplerTableTex1,vec2(dst.r,0.0)).b;  // note rgb -> bgr?
    dst.g = texture2D(SamplerTableTex1,vec2(dst.g,0.0)).g;
    dst.b = texture2D(SamplerTableTex1,vec2(dst.b,0.0)).r;
    
    outText = vec4(dst,1.0);
}