#version 110

varying vec2 texCoord;
uniform sampler2D tex;
uniform sampler2D palette;

void main()
{
	vec4 indexVec = texture2D(tex, texCoord);

	float index = indexVec.a;

	if(index == 0.0)
	{
		gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
	}
	else
	{
		vec4 texel = texture2D(palette, vec2(index, 0.0));
		gl_FragColor = vec4(texel.r, texel.g, texel.b, 1.0);
	}
}