/********************************************************************************
FILE		:	2DRender.fx
AUTHOR		:	Chad Taylor
DATE		:	2/9/07
TEAM		:	Double Hawk Games

All content (c) 2006-2007 DigiPen (USA) Corporation, all rights reserved.
********************************************************************************/
uniform extern float4x4 matViewProject;
uniform extern float4x4 matWorld;
uniform extern float4	colAmbient;
uniform extern texture	txTexture;

sampler TexSample = sampler_state
{
	Texture   = <txTexture>;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	AddressU  = CLAMP;
	AddressV  = CLAMP;
};

struct VS_OUTPUT
{
	float4 posH : POSITION;
	float2 tex0 : TEXCOORD0;
};

VS_OUTPUT VS(	float2 posS : POSITION0,
				float2 tex : TEXCOORD0 )
{
	VS_OUTPUT outVS = (VS_OUTPUT)0;
	
	outVS.posH.x = posS.x * 2.0f;
	outVS.posH.y = (1.0f - posS.y) * 2.0f;
	outVS.posH.xy -= float2( 1.0f, 1.0f );
	outVS.posH.z = 0.0f;
	outVS.posH.w = 1.0f;

	tex -= float2( 0.5f, 0.5f );
	tex = mul( float4( tex, 0.0f, 0.0f ), matWorld ).xy;
	tex += float2( 0.5f, 0.5f );
	
	outVS.tex0 = tex;

	return outVS;
}

float4 PS( float2 tex0 : TEXCOORD0 ) : COLOR
{
	// Grab the texture color
	return  tex2D( TexSample, tex0 ) * colAmbient;
}

technique TwoDRender
{
	pass P0
	{
		vertexShader		= compile vs_2_0 VS();
		pixelShader			= compile ps_2_0 PS();
		ZWriteEnable		= False;
		ZEnable				= False;
		CullMode			= None;
		AlphaBlendEnable	= True;
		SrcBlend			= SrcAlpha;
		DestBlend			= InvSrcAlpha;
	}
}
