Getting bumps from FrameBuffer. I used the method for removing edge defects as in ACCURATE method reconstruction of Normals.
Due to using DX9 and the pixel shift problem, I had to shift by 1 pixel float depth_c = tex2D(WPDepth, (i.P - 1)*TexBaseSize ).a;.
float4 main(PS_IN i ) : COLOR
{
float2 vpos = i.vTexCoord;
float2 ts1 = float2(1.0, 0.0) * TexBaseSize;
float2 ts2 = float2(0.0, 2.0) * TexBaseSize;
float2 ts3 = float2(0.0, 1.0) * TexBaseSize;
float2 ts4 = float2(2.0, 0.0) * TexBaseSize;
float3 colorRight = tex2D(FrameBuffer, vpos + ts1 ).rgb;
float3 colorLeft = tex2D(FrameBuffer, vpos + float2(-1.0, 0.0) * TexBaseSize ).rgb;
float3 colorTop = tex2D(FrameBuffer, vpos + ts3 ).rgb;
float3 colorBottom = tex2D(FrameBuffer, vpos + float2( 0.0,-1.0) * TexBaseSize ).rgb;
float depth_c = tex2D(WPDepth, (i.P - 1)*TexBaseSize ).a;
float4 H = float4(
tex2D(WPDepth,vpos - ts1).a,
tex2D(WPDepth,vpos - ts4).a,
tex2D(WPDepth,vpos + ts1).a,
tex2D(WPDepth,vpos + ts4).a
);
float4 V = float4(
tex2D(WPDepth,vpos - ts3).a,
tex2D(WPDepth,vpos - ts2).a,
tex2D(WPDepth,vpos + ts3).a,
tex2D(WPDepth,vpos + ts2).a
);
float2 he = abs((2.0*H.xz - H.yw) - depth_c);
float2 ve = abs((2.0*V.xz - V.yw) - depth_c);
float gradientX = he.x+bias < he.y ? 0 : Luminance( colorRight - colorLeft );
float gradientY = ve.x+bias < ve.y ? 0 : Luminance( colorTop - colorBottom );
float3 normal = float3(gradientX * strength, gradientY * strength, 1.0);
normal.z = sqrt(max(0.0, 1.0 - normal.x * normal.x - normal.y * normal.y));
return float4(normal * 0.5 + 0.5, 1);
};