float4x4 g_WorldMatrix;
float4x4 g_ViewMatrix;
float4x4 g_ProjectionMatrix;

float2 g_Viewport;

Texture2D g_Texture;


SamplerState samPoint
{
    Filter = MIN_MAG_MIP_POINT;
    
    AddressU = Wrap;
    AddressV = Wrap;
};

SamplerState samLinear
{
    Filter = MIN_MAG_MIP_LINEAR;
    
    AddressU = Wrap;
    AddressV = Wrap;
};

SamplerState samAniso
{
    Filter = ANISOTROPIC;
    MaxAnisotropy = 16;
    
    AddressU = Wrap;
    AddressV = Wrap;
};


BlendState AlphaBlending
{
    BlendEnable[0] = TRUE;
    SrcBlend = SRC_ALPHA;
    DestBlend = INV_SRC_ALPHA;
    BlendOp = ADD;
    RenderTargetWriteMask[0] = 0x0F;
};

BlendState DisableBlend 
{ 
	BlendEnable[0] = FALSE; 
};

DepthStencilState DepthEnabling 
{ 
	DepthEnable = TRUE; 
};

DepthStencilState DepthDisabling
{
	DepthEnable = FALSE;
};

RasterizerState DisableCulling
{
	CullMode = NONE;
};


struct VS_INPUT
{
    float4 Pos  : POSITION;
    float3 Norm : NORMAL;
    float3 Tang : TANGENT; 
    float2 Tex  : TEXCOORD;
};

struct PS_INPUT
{
    float4 Pos  : SV_Position;
    float2 Tex  : TEXCOORD0;
};


//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------
PS_INPUT SPRITE_VS( VS_INPUT input )
{
	PS_INPUT output = (PS_INPUT)0;
    
    output.Pos = mul(input.Pos, g_WorldMatrix);
    output.Pos = mul(output.Pos, g_ViewMatrix);
    output.Pos = mul(output.Pos, g_ProjectionMatrix);
    
    output.Tex = input.Tex;
    
	return output;
}


//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
float4 SPRITE_PS( PS_INPUT input) : SV_Target
{
	return g_Texture.Sample(samAniso, input.Tex);
}


//--------------------------------------------------------------------------------------
technique10 Render
{
    pass P0
    {
		SetRasterizerState(DisableCulling);
		SetBlendState( AlphaBlending, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
		SetDepthStencilState( DepthDisabling, 0 );
		
        SetVertexShader( CompileShader( vs_4_0, SPRITE_VS() ) );
        SetGeometryShader( NULL );
        SetPixelShader( CompileShader( ps_4_0, SPRITE_PS() ) );
    }
}