problem with Gaussian blur

Started by
2 comments, last by programci_84 12 years, 10 months ago
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

//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 BlurX_PShader(float2 TexC : TEXCOORD0):COLOR
{
float4 TexColor = tex2D(BP_sTex, TexC);

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

return TexColor/15.0f;
}

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

float4 BlurY_PShader(float2 TexC : TEXCOORD0):COLOR
{
float4 TexColor = tex2D(Blur_sTex, TexC);

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

return TexColor/15.0f;
}


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
Advertisement
You don't need to divide your result by 15, since you're already applying the Gaussian weights.
i did what you said and i am still getting no output whatsoever.
Take a look into "HDRLighting" sample in the SDK. It covers calculating blur coefficients and blurring very well.
There's no "hard", and "the impossible" takes just a little time.

This topic is closed to new replies.

Advertisement