// -------------------------------------------------------------
// 전역변수
// -------------------------------------------------------------
float fx = 0.5;
float fy = 0.5;

float  SpeedRatio = 0.0;
float4 vWeightsBW=float4(0.3,0.59,0.11,0);
float4 vWeightsSepia=float4(1.0,0.8,0.6,1); 
 
// -------------------------------------------------------------
// 텍스쳐
// -------------------------------------------------------------
// 베이스 텍스쳐
texture tex0;
texture tex1;
sampler BaseSamp = sampler_state
{
	Texture = <tex0>;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = NONE;
	
	AddressU = CLAMP;
	AddressV = CLAMP;
};
sampler BaseSamp2 = sampler_state
{
	Texture = <tex1>;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = NONE;
	
	AddressU = clamp;
	AddressV = clamp;
};


float4 PS(in float2 Tex : TEXCOORD0 ) : COLOR
{
	float2 tTex;
	float alpha = tex2D( BaseSamp2, Tex).a;
	float2 CenterTex;
	CenterTex.x = fx;
	CenterTex.y = fy;
	tTex = CenterTex - Tex;
	tTex = tTex * SpeedRatio*1.5f;
	float4 color1 = tex2D( BaseSamp, Tex);
	float4 color2 = tex2D( BaseSamp, Tex + tTex*1.0f/256.0f);
	float4 color3 = tex2D( BaseSamp, Tex + tTex*2.0f/256.0f);
	float4 color4 = tex2D( BaseSamp, Tex + tTex*3.0f/256.0f);
	float4 color5 = tex2D( BaseSamp, Tex + tTex*4.0f/256.0f);
	float4 color6 = tex2D( BaseSamp, Tex + tTex*5.0f/256.0f);
	
	float4 finalcolor =saturate(( color1+color2+color3+color4+color5+color6)/6.0f + pow(saturate(1.0f - saturate(length(tTex) / SpeedRatio)) * 0.25f, 4));
/*	
	float  brightness=dot(finalcolor,vWeightsBW);  
	finalcolor = brightness*vWeightsSepia; 	
*/	
	finalcolor.a = alpha * SpeedRatio * 0.5f;//SpeedRatio / 4.0f;// * pow((1.0f - saturate(length(tTex) / SpeedRatio)),10);
	return finalcolor;
}


technique tec0
{
   pass p0
   {
        VertexShader = null;
        PixelShader  = compile ps_2_0 PS();
   }
}
