# blur CGFX

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

## Recommended Posts

hi guys, i've copyed and paste a simple blur shader from this thread: http://www.gamedev.net/community/forums/topic.asp?topic_id=399427 here's the code :
half blur=-5;//=2;

half4 gaussianbluryPS( half2 Tex : TEXCOORD0 ) : COLOR0
{ static const int g_cKernelSize = 13;

half define = blur * 100 -300;

half2 TexelKernel[13] =
{
{ -6, 0 },
{ -5, 0 },
{ -4, 0 },
{ -3, 0 },
{ -2, 0 },
{ -1, 0 },
{ 0, 0 },
{ 1, 0 },
{ 2, 0 },
{ 3, 0 },
{ 4, 0 },
{ 5, 0 },
{ 6, 0 },
};

const half BlurWeights[13] =
{
0.002216,
0.008764,
0.026995,
0.064759,
0.120985,
0.176033,
0.199471,
0.176033,
0.120985,
0.064759,
0.026995,
0.008764,
0.002216,
};

half4 Color = 0;

for (int i = 0; i < 13; i++)
{
Color += tex2D( g_samSrcColor, Tex + TexelKernel[i].yx /define) * BlurWeights[i];
}

return Color;
}

///////////////////////////////////////////////////////////////

half4 gaussianblurxPS( half2 Tex : TEXCOORD0 ) : COLOR0
{ static const int g_cKernelSize = 13;

half define = blur * 100 -300;

half2 TexelKernel[13] =
{
{ -6, 0 },
{ -5, 0 },
{ -4, 0 },
{ -3, 0 },
{ -2, 0 },
{ -1, 0 },
{ 0, 0 },
{ 1, 0 },
{ 2, 0 },
{ 3, 0 },
{ 4, 0 },
{ 5, 0 },
{ 6, 0 },
};

const half BlurWeights[13] =
{
0.002216,
0.008764,
0.026995,
0.064759,
0.120985,
0.176033,
0.199471,
0.176033,
0.120985,
0.064759,
0.026995,
0.008764,
0.002216,
};

half4 Color = 0;

for (int i = 0; i < 13; i++)
{
Color += tex2D( g_samSrcColor, Tex + TexelKernel[i].xy /define) * BlurWeights[i];
}

return Color;
}


it implements blur with separable gaussian kernels. I've tryed it, and it works. However, there's one line i dont understand :
half define = blur * 100 -300;


what does it mean ? what is this 100 - 300 and why is it multiplyed by "blur" ? anyone has an idea ? thanks very much in advance. cheeeeeeeeeeeeers.

##### Share on other sites
half is a type
blur is defined near the top as -5.
I think the line is saying
define = (blur * 100) - 300;

Which becomes +700 I think. (It's late right now, and I'm tired.) Anyway, hope that helps. Math may be wrong though.

##### Share on other sites
Quote:
 Original post by Robo-Linkhalf is a typeblur is defined near the top as -5.I think the line is sayingdefine = (blur * 100) - 300;Which becomes +700 I think. (It's late right now, and I'm tired.) Anyway, hope that helps. Math may be wrong though.

hello,
yes i know what the equation does, but i don't know the mathematical meaning of it, sort of. Why the -800 ?? also, why is "blur" multiplyed by 100 then substracted 300 ? Is it supposed to be related to the center of the gaussian ? its weights ?? i don't know.

up

##### Share on other sites

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

## Create an account

Register a new account