#version 100
precision mediump float;

varying vec4 col;
varying vec3 nrm;
varying vec2 uv;

uniform sampler2D tex0;
uniform sampler2D tex1;
uniform sampler2D tex2;
uniform float lerp;

void main()
{
//	vec4 texcol = mix(texture2D(tex0,uv),texture2D(tex1,uv),lerp);
//	vec4 envcol = texture2D(tex2,nrm.xy * 0.5 + vec2(0.5,0.5) );
//	gl_FragColor = envcol*texcol;
	vec4 envcol = texture2D(tex1,nrm.xy * 0.5 + vec2(0.5,0.5) );
	vec4 texcol = texture2D(tex0, uv);
	if (texcol.r < lerp)texcol.a = 0.0;
	else texcol.a = 1.0;
	if (texcol.a <= 0.0)discard;
	gl_FragColor = texcol*envcol;
}
