varying vec2 pos;

uniform sampler2D tex0;
uniform sampler2D tex1;
uniform float focus;
uniform float focal;
uniform float time;

void main()
{
	vec2 uv = vec2((pos.x+1)/2.0, (pos.y+1)/2.0);
	vec4 col = texture2D(tex0,uv);
	vec3 blur = texture2D(tex1,uv).xyz;
	//float focus=100;
	float dist = col.w*100;
	
	//float

	vec3 c = col.xyz;
	//c /= dist/100.0;
	vec3 fog_color = vec3(1.0,0.5,0.5);
	float fv = min(dist/100.0,1.0);

	fv = min(abs(((dist-focus)/focal)), 1.0);

	c = c*(1.0-fv)+blur*fv;
	//c=blur;
	//c.x=fv;
	//c = vec3(0,0,0);
	gl_FragColor = vec4(c,1.0);
}