Jump to content
  • Advertisement
Sign in to follow this  
carmellose

blur CGFX

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

If you intended to correct an error in the post then please contact us.

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;


// 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.yx /define) * BlurWeights;
}

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.xy /define) * BlurWeights;
}

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
Advertisement
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!