cbuffer cbPerFrame
{
	float gMultiplierPercentage;
};

Texture2D gSyringeContainerTex;
Texture2D gSyringePusherTex;


SamplerState samAnisotropic
{
	Filter = ANISOTROPIC;
	MaxAnisotropy = 4;

	AddressU = CLAMP;
	AddressV = CLAMP;
};

struct VertexIn
{
	float3 PosL	: POSITION;
	float2 Tex	: TEXCOORD;
};

struct VertexOut
{
	float4 Pos	: SV_POSITION;
	float2 Tex	: TEXCOORD0;
};


VertexOut VS( VertexIn vIn )
{
	VertexOut vOut;

	vOut.Pos = float4( vIn.PosL.xy, 0.0f, 1.0f );
	vOut.Pos.xy -= 1.0f;

	//float screenHeight = 800.0f;
	//float screenWidth = 800.0f;

	//vOut.Pos.x = 
	//vOut.Pos.y = -vOut.Pos.y * screenHeight/2.0f + screenHeight/2.0f;
	
	vOut.Tex = vIn.Tex;
	//vOut.Tex.x = 0.5f * ( 1 + vIn.PosL.x );
	//vOut.Tex.y = 0.5f * ( 1 - vIn.PosL.y );

	return vOut;
}


float4 PS( VertexOut pIn ) : SV_TARGET
{
	float4 texColor = float4( 0.0f, 0.0f, 0.0f, 0.0f );

	float4 tempColor1 = float4( 0.0f, 0.0f, 0.0f, 0.0f );
	float4 tempColor2 = float4( 0.0f, 0.0f, 0.0f, 0.0f );

	float2 tempTexCoords = pIn.Tex;

	float percentage = gMultiplierPercentage / 100.0f;

	percentage /= 3.0f;

	tempTexCoords = pIn.Tex;
	tempTexCoords.y += percentage;

	tempColor2 = gSyringeContainerTex.Sample( samAnisotropic, pIn.Tex );

	if( pIn.Tex.y < 0.666666666666f && tempColor2.a < 0.5f )
		tempColor1 = gSyringePusherTex.Sample( samAnisotropic, tempTexCoords );

	if( tempColor1.a > 0.01f || tempColor2.a > 0.01f )
		texColor = float4( (tempColor1.xyz * ( 1.0f - tempColor2.w )) + (tempColor2.xyz * tempColor2.w), 1.0f );

	// Discard pixel if texture alpha < 0.1.
	clip( texColor.a - 0.1f );

	return texColor;
}


technique10 HUDTech
{
	pass P0
	{
		SetVertexShader( CompileShader( vs_4_0, VS() ) );
		SetGeometryShader( NULL );
		SetPixelShader( CompileShader( ps_4_0, PS() ) );
	}
}