uniform			sampler2DRect	sampler;
uniform			sampler2DRect	weightSampler;

void main()
{
	float	yOffset	=	floor(gl_TexCoord[1].x) + 0.5;

	vec2	p0		=	vec2(0.5,	yOffset);
	vec2	p1		=	vec2(1.5,	yOffset);
	vec2	p2		=	vec2(2.5,	yOffset);
	
	vec4	w0		=	texture2DRect(weightSampler, p0);
	vec4	w1		=	texture2DRect(weightSampler, p1);
	vec4	w2		=	texture2DRect(weightSampler, p2);
	float	leftPix	=	floor(w2.z * 255.0 + 0.5) * 255.0 + floor(w2.w * 255.0 + 0.5) + 0.5;
	
	float	mul		=	1.2;
	float	sub		=	0.2;
	w0				=	(w0 * vec4(mul)) - vec4(sub);
	w1				=	(w1 * vec4(mul)) - vec4(sub);
	w2				=	(w2 * vec4(mul)) - vec4(sub);

			p0		=	vec2(leftPix, gl_TexCoord[0].y);
			p1		=	vec2(p0.x + 1.0, p0.y);
			p2		=	vec2(p0.x + 2.0, p0.y);
	vec2	p3		=	vec2(p0.x + 3.0, p0.y);
	vec2	p4		=	vec2(p0.x + 4.0, p0.y);
	vec2	p5		=	vec2(p0.x + 5.0, p0.y);
	vec2	p6		=	vec2(p0.x + 6.0, p0.y);
	vec2	p7		=	vec2(p0.x + 7.0, p0.y);
	vec2	p8		=	vec2(p0.x + 8.0, p0.y);
	
	vec4	v0		=	texture2DRect(sampler,	p0);
	vec4	v1		=	texture2DRect(sampler,	p1);
	vec4	v2		=	texture2DRect(sampler,	p2);
	vec4	v3		=	texture2DRect(sampler,	p3);
	vec4	v4		=	texture2DRect(sampler,	p4);
	vec4	v5		=	texture2DRect(sampler,	p5);
	vec4	v6		=	texture2DRect(sampler,	p6);
	vec4	v7		=	texture2DRect(sampler,	p7);
	vec4	v8		=	texture2DRect(sampler,	p8);
	
	vec4	pixel;
	pixel			=	v0 * vec4(w0.y);
	pixel			+=	v1 * vec4(w0.z);
	pixel			+=	v2 * vec4(w0.w);
	pixel			+=	v3 * vec4(w1.x);
	pixel			+=	v4 * vec4(w1.y);
	pixel			+=	v5 * vec4(w1.z);
	pixel			+=	v6 * vec4(w1.w);
	pixel			+=	v7 * vec4(w2.x);
	pixel			+=	v8 * vec4(w2.y);
	
	gl_FragColor	=	pixel;
}
