
//================================================================
//大域設定値
//Texture
sampler sampler0_ : register(s0);

//--------------------------------
//ゆがみ生成用パラメータ
static const float RENDER_WIDTH = 1024; //レンダリングテクスチャの幅
static const float RENDER_HEIGHT = 1024; //レンダリングテクスチャの高さ
static const float RENDER_PIX_X = 2.0f/1024.0f;
static const float RENDER_PIX_Y = 2.0f/1024.0f;
static const float WIGHT[3] =
	{  4.0f/16.0f, 2.0f/16.0f, 1.0f/16.0f };


//================================================================
//--------------------------------
//ピクセルシェーダ入力値
struct PS_INPUT
{
	float4 diffuse : COLOR0;  //ディフューズ色
	float2 texCoord : TEXCOORD0; //テクスチャ座標
	float2 vPos : VPOS; //描画先座標
};

//--------------------------------
//ピクセルシェーダ出力値
struct PS_OUTPUT
{
    float4 color : COLOR0; //出力色
};


//================================================================
// シェーダ
//--------------------------------
//ピクセルシェーダ
PS_OUTPUT PsGaussian( PS_INPUT In ) : COLOR0
{
	PS_OUTPUT Out;

	//テクスチャの色
	float4 colorTexture = WIGHT[0] * tex2D(sampler0_, In.texCoord);
	//合成
	colorTexture += WIGHT[1] * 
		(tex2D(sampler0_, In.texCoord + float2(0,  RENDER_PIX_Y) ) +
		 tex2D(sampler0_, In.texCoord + float2(0, -RENDER_PIX_Y) ) +
		 tex2D(sampler0_, In.texCoord + float2( RENDER_PIX_X, 0) ) +
		 tex2D(sampler0_, In.texCoord + float2(-RENDER_PIX_X, 0) ));
	colorTexture += WIGHT[2] * 
		(tex2D(sampler0_, In.texCoord + float2( RENDER_PIX_X, RENDER_PIX_Y) ) +
		 tex2D(sampler0_, In.texCoord + float2(-RENDER_PIX_X, RENDER_PIX_Y) ) +
		 tex2D(sampler0_, In.texCoord + float2( RENDER_PIX_X,-RENDER_PIX_Y) ) +
		 tex2D(sampler0_, In.texCoord + float2(-RENDER_PIX_X,-RENDER_PIX_Y) ));

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

	//合成
	Out.color = colorTexture * colorDiffuse;

	return Out;
}


//================================================================
//--------------------------------
//technique
technique TecGaussian
{
	pass P0
	{
		PixelShader = compile ps_3_0 PsGaussian();
	}
}

