
//================================================================
//ݒl
//Texture
sampler sampler0_ : register(s0);

//--------------------------------
//}XNpeNX`
// ؂͈
float4 posFrame_;	// [x, y, width, height]

texture textureMask_;

sampler samplerMask_ = sampler_state
{ 
	Texture = <textureMask_>;
};

//================================================================
//--------------------------------
//sNZVF[_͒l
struct PS_INPUT
{
	float4 diffuse : COLOR0;  //fBt[YF
	float2 texCoord : TEXCOORD0; //eNX`W
	float2 vPos : VPOS; //`W
};

//--------------------------------
//sNZVF[_o͒l
struct PS_OUTPUT
{
    float4 color : COLOR0; //o͐F
};


//================================================================
// VF[_
//--------------------------------
//sNZVF[_
PS_OUTPUT PsMask( PS_INPUT In ) : COLOR0
{
	PS_OUTPUT Out;

	//eNX`̐F
	float4 colorTexture = tex2D(sampler0_, In.texCoord);

	//_fBt[YF
	float4 colorDiffuse = In.diffuse;

	//
	float4 color = colorTexture * colorDiffuse;
	Out.color = color;

	//--------------------------------
	float2 maskUV;

	//`悩}XNpeNX`̈ʒuvZ
	maskUV.x = (In.vPos.x - posFrame_[0]) / posFrame_[2];
	maskUV.y = (In.vPos.y - posFrame_[1]) / posFrame_[3];
	float4 colorMask = tex2D(samplerMask_, maskUV);

	//}XNRGBlo͌ʂ̃lƂč
	Out.color.rgb = colorMask.rgb * color.a * (color.r + color.g + color.b) * 0.33333f;

	return Out;
}


//================================================================
//--------------------------------
//technique
technique TecMask
{
	pass P0
	{
		PixelShader = compile ps_3_0 PsMask();
	}
}

