I've tried to find a way to use variable samples while calculating the blur, but the calculations involved in creating the gaussian function's result are too complex for PS2.0.
Here you only have 7 samples, as this is quite expansive in terms of operations. If you want a version with more samples, it should be divided in 2 separate shaders (or maybe passes ?).
You can control the distance of the blur and the intensity of the image in construct.
Save it with the notepad as a .fx file and place it into construct's effects folder.
EDIT : changed the filtering from point to linear.
//DistanceMultisampleBlur
// Valerien
//PS2.0
//Distance blur with 7 samples.
//BORDER-MODE
//#PARAM float distance 1 : distance : modifies the distance of the blur
float distance;
//#PARAM float intensityDivide 2 : intensityDivide : affects the intensity of the resulting image. 2 produces a normal image.
float intensityDivide;
texture ForegroundTexture;
float pixelWidth;
float pixelHeight;
sampler2D foreground = sampler_state {
Texture = (ForegroundTexture);
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
float pixelKernel[7] =
{
3,
2,
1,
0,
-1,
-2,
-3,
};
float pixelWeights[7] =
{
0.015625,
0.09375,
0.234375,
0.3125,
0.234375,
0.09375,
0.015625,
};
float4 EffectProcess( float2 Tex : TEXCOORD0 ) : COLOR0
{
float4 color = 0;
float2 texCoord = 0;
for(int i=0; i < 7; i++)
{
texCoord.x = Tex.x + pixelKernel[i] * pixelWidth * distance;
//texCoord.y = Tex.y + pixelKernel[i] * pixelHeight * distance;
texCoord.y = Tex.y;
color += tex2D(foreground, texCoord.xy)* pixelWeights[i] /intensityDivide;
}
for(int i=0; i < 7; i++)
{
texCoord.y = Tex.y + pixelKernel[i] * pixelWidth * distance;
//texCoord.y = Tex.y + pixelKernel[i] * pixelHeight * distance;
texCoord.x = Tex.x;
color += tex2D(foreground, texCoord.xy)* pixelWeights[i] / intensityDivide;
}
return color;
}
// ConstructEffect
technique ConstructEffect
{
pass p0
{
VertexShader = null;
PixelShader = compile ps_2_0 EffectProcess();
}
}[/code:1ruyd2zp]