# problem with Gaussian blur

## Recommended Posts

VISQI    113
Hey guys
I was having a bit of trouble with my gaussian blur implementation. I am doing the weights and the sampling correctly but i still am getting zero output.

here is the FX file
[code]
//Weights

static const float Sigma = 1.0f;
static const float g = 1.0f / sqrt(2.0f*3.141592654*Sigma);

float BlurWeights[]
= {g * exp(-49/(2.0f*Sigma*Sigma)) , g * exp(-36/(2.0f*Sigma*Sigma)) , g * exp(-25/(2.0f*Sigma*Sigma)) , g * exp(-16/(2.0f*Sigma*Sigma)),
g * exp(-9/(2.0f*Sigma*Sigma)) , g * exp(-4/(2.0f*Sigma*Sigma)) , g * exp(-1/(2.0f*Sigma*Sigma)) , g ,
g * exp(-1/(2.0f*Sigma*Sigma)) , g * exp(-4/(2.0f*Sigma*Sigma)) , g * exp(-9/(2.0f*Sigma*Sigma)) , g * exp(-16/(2.0f*Sigma*Sigma)),
g * exp(-25/(2.0f*Sigma*Sigma)) , g * exp(-36/(2.0f*Sigma*Sigma)) , g * exp(-49/(2.0f*Sigma*Sigma)) };

//Blur on The X-Axis
//========================================

{
float4 TexColor = tex2D(BP_sTex, TexC);

for(int i = 0; i < 15; i++)
{
TexColor += tex2D(BP_sTex, TexC + ((i-7)/SourceDimensions.x) ) * BlurWeights[i];
}

return TexColor/15.0f;
}

//Blur on The Y-Axis
//========================================

{
float4 TexColor = tex2D(Blur_sTex, TexC);

for(int i = 0; i < 15; i++)
{
TexColor += tex2D(Blur_sTex, TexC + ( (i-7)/SourceDimensions.y) ) * BlurWeights[i];
}

return TexColor/15.0f;
}
[/code]

Here are my steps:
- BeginScene() with the Blur texture as a render target
- Apply the BlurX Technique
- EndScene()

- BeginScene() with the Blur texture as a render target
- Take the Blur texture and apply the BlurY technique on it.
- EndScene()

Thanks for the help

##### Share on other sites
MJP    19788
You don't need to divide your result by 15, since you're already applying the Gaussian weights.

##### Share on other sites
VISQI    113
i did what you said and i am still getting no output whatsoever.

##### Share on other sites
programci_84    336
Take a look into "HDRLighting" sample in the SDK. It covers calculating blur coefficients and blurring very well.