uniform sampler2D tex0;

uniform sampler1D red;
uniform sampler1D green;
uniform sampler1D blue;
uniform sampler1D alpha;

void main(void)
{
	vec4 texel = texture2D(tex0, gl_TexCoord[0].st);

	float rr = texture1D(alpha, texel.r).r;
	float rg = texture1D(alpha, texel.g).r;
	float rb = texture1D(alpha, texel.b).r;

	float r = texture1D(red, rr).r;
	float g = texture1D(green, rg).r;
	float b = texture1D(blue, rb).r;

	gl_FragData[0] = vec4(r,g,b,texel.a);
}


