/*varying vec2 		texcoord;
uniform sampler2D 	tex,
					pos;
uniform float		scale;
uniform float		ofs;
varying vec2		t0,t1,t2,t3,t4,t5;

//vec2			d=vec2(ofs*0.5,0.0);

void main()
{
	float dc=-texture2D(pos, texcoord);
	vec4 color=texture2D(tex, texcoord);

	// is out focus
	if(color.a<1.0)
	{
		gl_FragColor =	(
				texture2D(tex, t0)*0.25+ // *step(dc,-texture2D(pos, t0))+
				texture2D(tex, t1)*0.125+// *step(dc,-texture2D(pos, t1))+
				texture2D(tex, t2)*0.0625+ //*step(dc,-texture2D(pos, t2))+
				
				texture2D(tex, t3)*0.25+ //*step(dc,-texture2D(pos, t3))+
				texture2D(tex, t4)*0.125+ //*step(dc,-texture2D(pos, t4))+
				texture2D(tex, t5)*0.0625+ //*step(dc,-texture2D(pos, t5))+
		
				color*0.5
				)*scale;
	}
	else
	{
		// in focus
		gl_FragColor = color;
	}
}*/

varying vec2 		texcoord;
uniform sampler2D 	tex,
					pos;
uniform float		scale;
uniform float		ofs;
//varying vec2		t0,t1,t2,t3,t4,t5;

//vec2			d=vec2(0.0,ofs*0.5);


void main()
{
	vec4 color=texture2D(tex, texcoord);
	float yofs=ofs*(1.0-color.a);
	// is out focus
/*	if(color.a<1.0)
	{*/
		//float 	dc=-texture2D(pos, texcoord);
		vec4  	acc;
		
		vec4	c0=texture2D(tex,texcoord+vec2(0.0,-yofs));
		vec4	c3=texture2D(tex,texcoord+vec2(0.0,yofs));
		yofs+=ofs;
		vec4	c1=texture2D(tex, texcoord+vec2(0.0,-yofs));
		vec4	c4=texture2D(tex, texcoord+vec2(0.0,yofs));
		yofs+=ofs;
		vec4	c2=texture2D(tex, texcoord+vec2(0.0,-yofs));
		vec4	c5=texture2D(tex, texcoord+vec2(0.0,yofs));
			
		acc.rgb=c0.rgb*0.25+c1.rgb*0.125+c2.rgb*0.0625+c3.rgb*0.25+c4.rgb*0.125+c5.rgb*0.0625+color.rgb*0.5;
		acc.rgb*=vec3(scale);
		
	/*	if(c0.a<1.0 || dc<-texture2D(pos, t0))
			acc.a+=c0.a*0.25;
		
		if(c1.a<1.0 || dc<-texture2D(pos, t1))
			acc.a+=c1.a*0.125;
			
		if(c2.a<1.0 || dc<-texture2D(pos, t2))
			acc.a+=c2.a*0.0625;

		if(c3.a<1.0 || dc<-texture2D(pos, t3))				
			acc.a+=c3.a*0.25;
		
		if(c4.a<1.0 || dc<-texture2D(pos, t4))			
			acc.a+=c4.a*0.125;
		
		if(c5.a<1.0 || dc<-texture2D(pos, t5))			
			acc.a+=c5.a*0.0625;*/
						
		gl_FragColor.rgb = acc.rgb;	
		gl_FragColor.a=color.a;
/*	}
	else
	{
		// in focus
		gl_FragColor = color;
	}*/
}