Sign in to follow this  
VISQI

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 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[i];
}

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[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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this