problem with Gaussian blur

This topic is 2544 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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

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

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

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

• 10
• 16
• 14
• 18
• 15