#ifdef GL_ES
precision mediump float;
#endif
uniform sampler2D   u_tex0; // Tile Data
uniform sampler2D   u_tex1; // Ground Pattern
uniform sampler2D   u_tex2; // Tile Mask
uniform sampler2D   u_tex3; // Tile Mask
varying vec2        v_texture;
varying vec2        v_textureB;
varying vec4	    v_col;
void main()
	{
	vec4 colTile = texture2D(u_tex0, v_texture);
	vec4 colMask = texture2D(u_tex2, v_texture);
	vec3 colA = mix(colTile.rgb, texture2D(u_tex1, v_textureB).rgb, colMask.r);
	vec3 colB = mix(colA, texture2D(u_tex3, v_textureB).rgb, colMask.g);
	gl_FragColor = vec4(colB, colTile.a) * v_col; // vec4(col.rgb * col.a * 0.5f, texture2D(u_tex1, v_texture).a);
	}