varying vec2 		texcoord;
uniform sampler2D 	tex,
					bump,
					diff;
vec3 				normal;
uniform float 		alpha;


void main()
{
	normal=normalize(texture2D(bump,texcoord).xyz*2.0-1.0);
	
	vec4 color=texture2D(diff,texcoord);
	color.rgb=pow(color.rgb,vec3(2.2));
	
	vec3 bgColor=/*pow(*/texture2D(tex,texcoord).xyz/*,vec3(2.2))*/;
	
	vec2 UV=texcoord.xy;//*0.5+0.5;
	UV+=normal.xy*0.025;
	
	float A=clamp(color.a,0.0,1.0);//max(color.a-(1.0-alpha),0.0);
	//if(A<0.25) A=0.0;
	
	vec3 refractedColor=/*pow(*/texture2D(tex,UV).xyz/*,vec3(2.2))*/*color.xyz;
	
	gl_FragColor.xyz = /*pow(*/mix(bgColor,refractedColor,min(A*A*10.0,1.0))/*,vec3(1.0/2.2))*/;
}
