uniform sampler2D s_tex0;
uniform sampler2D s_texL; // L-tex
uniform sampler2D s_texUV; // UV-tex


uniform vec4 u_blendcolor;

varying vec2 v_texcoord;

vec3 LUV_2_RGB_color(in vec3 LUV)
{
	return vec3(	LUV.x + 1.402 * LUV.z,
    				LUV.x - 0.714 * LUV.z - 0.344 * LUV.y,
    				LUV.x + 1.772 * LUV.y	);
}

void main()
{	
    vec3 LUV;

    LUV.x = texture2D( s_texL, v_texcoord ).r;
    LUV.yz = texture2D( s_texUV, v_texcoord).rg - vec2(0.5);

	LUV.z += texture2D( s_tex0, v_texcoord ).r*0.00001; // just make sure, s_tex0 is not optimized away...
	LUV.z = min(LUV.z, 1.0);

	//gl_FragColor = texture2D(s_tex0, v_texcoord) * u_blendcolor;
	gl_FragColor.rgb = LUV_2_RGB_color(LUV);
    gl_FragColor.a = 1.0;
    gl_FragColor *= u_blendcolor;
} 
