Original Post
I've been working on a shader to blur the screen based on an alpha image (trying to get a sort of large blur on the outside moving into totally clear, a sort of dreamy look). Sort of like this http://nudel.omega2k3.de/blur_gradient.jpg The shader I have so far Pixel Shader
#include "common_ps_fxc.h"
sampler fb : register( s0 ); //frontbuffer
sampler alpha : register( s1 ); //alphasampler
const HALF sampledist : register(c0);
const HALF2 samples[8] = {
-1, -1,
0, -1,
1, -1,
-1, 0,
1, 0,
-1, 1,
0, 1,
1, 1,
};
HALF4 main( HALF2 iTexCoord : TEXCOORD0 ) : COLOR
{
float4 color = tex2D(fb, iTexCoord);
float4 bnw = tex2D(alpha, iTexCoord);
float4 avg = color;
for (int i = 0; i < 8; i++){
avg += tex2D(fb, iTexCoord + sampledist * samples);
}
avg /= 9;
return lerp(avg, color, bnw);
} Vertex Shader #include "common_vs_fxc.h"
struct VS_INPUT
{
float3 vPos : POSITION;
float2 vBaseTexCoord : TEXCOORD0;
};
struct VS_OUTPUT
{
float4 vProjPos : POSITION;
float2 vBaseTexCoord0 : TEXCOORD0;
};
VS_OUTPUT main( const VS_INPUT v )
{
VS_OUTPUT o = ( VS_OUTPUT )0;
float4 vProjPos = float4( v.vPos, 1.0f );
o.vProjPos = vProjPos;
o.vBaseTexCoord0 = v.vBaseTexCoord;
return o;
}
The problem is that the resulting image I get doesn't blur, but rather produces a ghosting effect in the area thats meant to blur http://www.wraiyth.com/files/nf/blurimage.jpg Anyone got any suggestions or ideas as to why its doing that and not blurring/