Sign in to follow this  
carmellose

blur CGFX

Recommended Posts

carmellose    122
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;


// Pixel Shader: HorizontalBlur

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;
}

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


// Pixel Shader: vertical Blur
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 this post


Link to post
Share on other sites
Robo-Link    100
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 this post


Link to post
Share on other sites
carmellose    122
Quote:
Original post by Robo-Link
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.


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.

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