uniform			sampler2DRect sampler;

// k2vuyPixelFormat

vec4 rgb_to_2vuy(
				vec4					colour1,
				vec4					colour2)
{
	vec4		yuvPixel;

//	BT.601
	const vec4				y_values	=	vec4( 0.256788,		 0.504129,		 0.097906,		0.0);
	const vec4				u_values	=	vec4(-0.148223,		-0.290993,		 0.439216,		0.0);
	const vec4				v_values	=	vec4( 0.439216,		-0.367789,		-0.071427,		0.0);
	const vec4				norm_values	=	vec4(128.0/255.0,	16.0/255.0,		128.0/255.0,	16.0/255.0);

	// Intel endian
	yuvPixel.b	=			(dot(u_values, colour2) + dot(u_values, colour1)) * 0.5;
	yuvPixel.g	=			dot(y_values, colour1);
	yuvPixel.r	=			(dot(v_values, colour2) + dot(v_values, colour1)) * 0.5;
	yuvPixel.a	=			dot(y_values, colour2);
	yuvPixel	+=			norm_values;

	return yuvPixel;
}

void main()
{
	vec4			yuvPixel	=	rgb_to_2vuy(	texture2DRect(sampler, vec2(gl_TexCoord[0])),
													texture2DRect(sampler, vec2(gl_TexCoord[1])));
	gl_FragColor	=	yuvPixel;

//	gl_FragColor.r	=	gl_TexCoord[0].x;
//	gl_FragColor.g	=	gl_TexCoord[0].y;
//
//	gl_FragColor.b	=	gl_TexCoord[1].x;
//	gl_FragColor.a	=	gl_TexCoord[1].y;
}