

sampler sampler0_ : register(s0);

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

float iscale_x;
float iscale_y;
float iw;
float ih;
float offset_x;
float offset_y;

struct PS_INPUT{
	float4 diffuse : COLOR0;
	float2 texCoord : TEXCOORD0;
	float2 vPos : VPOS;
};
struct PS_OUTPUT{
    float4 color : COLOR0;
};

PS_OUTPUT PsShader(PS_INPUT In) : COLOR0{
	PS_OUTPUT Out;

	float4 colorTexture = tex2D(sampler0_,In.texCoord);
	float4 colorDiffuse = In.diffuse;
	float4 color = colorTexture * colorDiffuse;
	
	float2 maskUV = (In.vPos+float2(offset_x,offset_y))/float2(iw,ih);
	maskUV *= float2(iscale_x,iscale_y);

	float4 colorMask = tex2D(samplerMask_,maskUV);

	color.a *= colorMask.a;

	Out.color = color;
	return Out;
}

technique TecMask{
	pass P0{
		PixelShader = compile ps_3_0 PsShader();
	}
}

