
sampler sampler0_ : register(s0);

const float SCREEN_WIDTH = 1280;
const float SCREEN_HEIGHT = 1280;

float PosX_;
float PosY_;

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


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


struct PS_OUTPUT
{
    float4 color : COLOR0; 
};


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

	//テクスチャの色
	float4 colorTexture = tex2D(sampler0_, In.texCoord);

	//頂点ディフーズ色
	float4 colorDiffuse = In.diffuse;

	//合成
	float4 color = colorTexture * colorDiffuse;

	//モノトーンの計算
	Out.color.r = ( color.r ) * 1;
	Out.color.g = ( color.g ) * 0.0;
	Out.color.b = ( color.b ) * 0.0;
	//Out.color.rgb = ( color.r + color.g + color.b ) * 0.88;
	Out.color.a = color.a;

	return Out;
}
PS_OUTPUT PsMonoChrom( PS_INPUT In ) : COLOR0
{
	PS_OUTPUT Out;

	//テクスチャの色
	float4 colorTexture = tex2D(sampler0_, In.texCoord);

	//頂点ディフーズ色
	float4 colorDiffuse = In.diffuse;

	//合成
	float4 color = colorTexture * colorDiffuse;


	Out.color.rgb = ( color.r + color.g + color.b ) * 1;
	Out.color.a = color.a;

	return Out;
}

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;
	maskUV.x = (In.vPos.x - to_x) / (SCREEN_WIDTH);
	maskUV.y = (In.vPos.y - to_y) / (SCREEN_HEIGHT);
	float4 colorMask = tex2D(samplerMask_,maskUV);
	
	if(isReverse){
		colorMask.rgb = 1 - colorMask.rgb;
	}

	color.a *= (colorMask.r + colorMask.g + colorMask.b) * 0.3333f;
	*/
	
	Out.color = color;
	
	if(color.a > 0){
		float2 maskUV;

		maskUV.x = In.vPos.x / SCREEN_WIDTH;
		maskUV.y = In.vPos.y / SCREEN_HEIGHT;
		float4 colorMask = tex2D(samplerMask_, maskUV);

		Out.color.a = ( colorMask.r + colorMask.g + colorMask.b ) * 0.3333f * color.a;
	}

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

technique TecMonoRed
{
	pass P0
	{
		PixelShader = compile ps_3_0 PsMonoRed();
	}
}
technique TecMonoChrom
{
	pass P0
	{
		PixelShader = compile ps_3_0 PsMonoChrom();
	}
}

