• Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

We're also offering banner ads on our site from just \$5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.

### #ActualSirIgor

Posted 04 April 2013 - 10:10 AM

Update: The problem is solved. Thanks.

We're trying to implement 2-pass Gaussian blur on HSL2.0. Here is a code of shader for horizontal blur. Pixelwidth is a radius. This shader doesn't work, the result looks as without the shader, please can you help?

sampler s0: register(s0);

float1 pixelwidth: register(c0);

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

static const float 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,
};

float1 Clip(float1 arg): float1
{
if (arg<0) arg=0;
if (arg>1) arg=1;
return arg;
}

float4 main_ps(float2 tex: TEXCOORD0):COLOR
{
float4 cl=(0,0,0,0);
float2 coord=tex;
for (int i=0; i<13; i++){
coord.x=Clip(tex.x+PixelKernel[i]*pixelwidth);
cl+=tex2D(s0, coord)*BlurWeights[i];
}
return cl;
}


### #1SirIgor

Posted 03 April 2013 - 07:45 AM

We're trying to implement 2-pass Gaussian blur on HSL2.0. Here is a code of shader for horizontal blur. Pixelwidth is a radius. This shader doesn't work, the result looks as without the shader, please can you help?

sampler s0: register(s0);

float1 pixelwidth: register(c0);

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

static const float 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,
};

float1 Clip(float1 arg): float1
{
if (arg<0) arg=0;
if (arg>1) arg=1;
return arg;
}

float4 main_ps(float2 tex: TEXCOORD0):COLOR
{
float4 cl=(0,0,0,0);
float2 coord=tex;
for (int i=0; i<13; i++){
coord.x=Clip(tex.x+PixelKernel[i]*pixelwidth);
cl+=tex2D(s0, coord)*BlurWeights[i];
}
return cl;
}


PARTNERS