Copy & Paste this in a new .fx text file
Code:
// Pixel shader input structure
struct PS_INPUT
{
float4 Position : POSITION;
float2 Texture : TEXCOORD0;
};
// Pixel shader output structure
struct PS_OUTPUT
{
float4 Color : COLOR0;
};
// Global variables
sampler2D Tex0;
float fCoeff;
PS_OUTPUT ps_main( in PS_INPUT In )
{
// Output pixel
PS_OUTPUT Out;
PS_OUTPUT TexT;
PS_OUTPUT TexTL;
PS_OUTPUT TexL;
PS_OUTPUT TexBL;
PS_OUTPUT TexB;
PS_OUTPUT TexBR;
PS_OUTPUT TexR;
PS_OUTPUT TexTR;
//CS_Blur
TexT.Color = tex2D(Tex0, float2(In.Texture.x,In.Texture.y-
fCoeff));
TexTL.Color = tex2D(Tex0, float2(In.Texture.x-
fCoeff,In.Texture.y-fCoeff));
TexL.Color = tex2D(Tex0, float2(In.Texture.x-
fCoeff,In.Texture.y));
TexBL.Color = tex2D(Tex0, float2(In.Texture.x-
fCoeff,In.Texture.y+fCoeff));
TexB.Color = tex2D(Tex0, float2
(In.Texture.x,In.Texture.y+fCoeff));
TexBR.Color = tex2D(Tex0, float2(In.Texture.x
+fCoeff,In.Texture.y+fCoeff));
TexR.Color = tex2D(Tex0, float2(In.Texture.x
+fCoeff,In.Texture.y));
TexTR.Color = tex2D(Tex0, float2(In.Texture.x
+fCoeff,In.Texture.y-fCoeff));
Out.Color = tex2D(Tex0, float2
(In.Texture.x,In.Texture.y));
Out.Color = (Out.Color+TexT.Color+TexTL.Color+TexL.Color
+TexBL.Color+TexB.Color+TexBR.Color+TexR.Color+TexTR.Color)/9;
//monochrome
float4 f4 = (Out.Color+TexT.Color+TexTL.Color+TexL.Color
+TexBL.Color+TexB.Color+TexBR.Color+TexR.Color+TexTR.Color)/9 *
float4(0.299f, 0.587f, 0.114f, 1.0f);
float f = f4.r + f4.g + f4.b;
Out.Color.rgb = f;
return Out;
}
// Effect technique
technique tech_main
{
pass P0
{
// shaders
VertexShader = NULL;
PixelShader = compile ps_2_0 ps_main();
}
}
--------------------------------------------------------
The only thing I did was made sure the Out.Color = (Out.Color+TexT.Color+TexTL.Color+TexL.Color+TexBL .Color+TexB.Color+TexBR.Color+TexR.Color+TexTR.Col or)/9) * the float4 of the monochrome value. The only parameter you need is the fCoeff which is for adjusting the blur.
--------------------------------------------------------
For the .xml document you can make it however it want, but here is how I structured it:
Code:
<effect>
<name>MonoChrome + Blur Shader Example</name>
<description>Monochrome does not have any parameters. Blur provides Blurring through the coefficient parameter.</description>
<parameter>
<name>Coeff</name>
<code>fCoeff</code>
<description>Blur offset coefficient</description>
<type>float</type>
<property>edit</property>
<value>0.01</value>
<min>0.0</min>
<max>0.5</max>
</parameter>
</effect>
--------------------------------------------------------

View MFA
Edit: I just realized you wanted directional blur instead of just a regular blur..err copy this instead to the .fx file:
Code:
// Pixel shader input structure
struct PS_INPUT
{
float4 Position : POSITION;
float2 Texture : TEXCOORD0;
};
// Pixel shader output structure
struct PS_OUTPUT
{
float4 Color : COLOR0;
};
// Global variables
sampler2D Tex0;
float fCoeff;
float fAngle;
PS_OUTPUT ps_main( in PS_INPUT In )
{
// Output pixel
PS_OUTPUT Out;
PS_OUTPUT OutA;
PS_OUTPUT OutB;
fAngle = fAngle*0.0174532925f;
OutA.Color = tex2D(Tex0, float2(In.Texture.x+cos(fAngle)
*fCoeff,In.Texture.y+sin(fAngle)*fCoeff));
OutB.Color = tex2D(Tex0, float2(In.Texture.x-cos(fAngle)
*fCoeff,In.Texture.y-sin(fAngle)*fCoeff));
Out.Color = tex2D(Tex0, In.Texture.xy);
Out.Color = (Out.Color+OutA.Color+OutB.Color)/3;
//monochrome
float4 f4 = (Out.Color+OutA.Color+OutB.Color)/3 * float4
(0.299f, 0.587f, 0.114f, 1.0f);
float f = f4.r + f4.g + f4.b;
Out.Color.rgb = f;
return Out;
}
// Effect technique
technique tech_main
{
pass P0
{
// shaders
VertexShader = NULL;
PixelShader = compile ps_2_0 ps_main();
}
}
--------------------------------------------------------
and the .xml file :
Code:
<effect>
<name>MonoChrome + Directional Blur Shader Example</name>
<description>Monochrome does not have any parameters. DirBlur provides Blurring through direction and coefficient.</description>
<parameter>
<name>Coefficient</name>
<code>fCoeff</code>
<description>Strength of the blur.</description>
<type>float</type>
<property>edit</property>
<value>0.1</value>
</parameter>
<parameter>
<name>Angle</name>
<code>fAngle</code>
<description>direction of the blur.</description>
<type>float</type>
<property>edit</property>
<value>45</value>
</parameter>
</effect>