matrix World;
matrix View;
matrix Projection;

struct vsInput
{
	float4 Pos 	: POSITION;
	float2 Tex 	: TEXCOORD;
};

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

SamplerState PointSampler
{
	Filter = MIN_MAG_MIP_POINT;
	AddressU = Clamp;
	AddressV = Clamp;
};

//=============================================================================

psInput vShader(vsInput input)
{
	psInput output;
	
	output.Pos = mul(input.Pos, World);
	output.Pos = mul(output.Pos, View);
	output.Pos = mul(output.Pos, Projection);	
	output.Tex = input.Tex;

	return output;
}

//=============================================================================

Texture2D InputTex;
float fScalar = 1.f;

float4 pShader(psInput input) : SV_Target
{
	return InputTex.Sample(PointSampler, input.Tex) * fScalar;
}

//=============================================================================
DepthStencilState NoDepthStencil
{
	DepthEnable = false;
	StencilEnable = false;
};

DepthStencilState Stenciled
{
	DepthEnable = false;

	StencilEnable = true;
	StencilReadMask  = 0xFFFFFFFF;
	StencilWriteMask = 0;

    	BackFaceStencilFunc = Equal;
	BackFaceStencilPass = Keep;
};

technique10 Default
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_4_0, vShader()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_4_0, pShader()));
		SetDepthStencilState(NoDepthStencil, 0);
	}
}

technique10 RawStenciled
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_4_0, vShader()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_4_0, pShader()));
		SetDepthStencilState(Stenciled, 1);
	}
}
//=============================================================================