/**
 * Copyright 1998-2010 Epic Games, Inc. All Rights Reserved.
 */

sampler tex0;
sampler tex1;
sampler tex2;
sampler tex3;
float4  tor;
float4  tog;
float4  tob;
float4  consts;

struct VS_IN
{
	float4 Position : POSITION;
	float2 T0 : TEXCOORD0;
};

struct VS_OUT
{
	float2 T0: TEXCOORD0;
};

float4 YCrCbToRGBNoPixelAlpha( VS_OUT In ) : COLOR
{
	float4 c;
	float4 p;
	c.x = tex2D( tex0, In.T0 ).x;
	c.y = tex2D( tex1, In.T0 ).x;
	c.z = tex2D( tex2, In.T0 ).x;
	c.w = consts.x;
	p.x = dot( tor, c );
	p.y = dot( tog, c );
	p.z = dot( tob, c );
	p.w = consts.w;
	return p;
}

//
// simple pixel shader to apply the yuvtorgb matrix with alpha
//

float4 YCrCbAToRGBA( VS_OUT In ) : COLOR
{
	float4 c;
	float4 p;
	c.x = tex2D( tex0, In.T0 ).x;
	c.y = tex2D( tex1, In.T0 ).x;
	c.z = tex2D( tex2, In.T0 ).x;
	c.w = consts.x;
	p.w = tex2D( tex3, In.T0 ).x;
	p.x = dot( tor, c );
	p.y = dot( tog, c );
	p.z = dot( tob, c );
	p.w *= consts.w;
	return p;
}

void VertexShaderMain(
	in VS_IN In,
	out VS_OUT Out,
	out float4 OutPosition : POSITION
	)
{
	OutPosition = In.Position;
	Out.T0 = In.T0;
}