# Results of Gaussian Blur are white.

I’ve been attempting to code a normal Gaussian Blur shader which scales the image down to half the size in the vertex shader. The scaling works, but when I attempted to code the gaussian blur my results are coming out white and sadly I don’t have enough knowledge to figure out why this is the case. Here is how I’m doing things at the moment:

``````
float offset[5] = { 0.0, 1.0, 2.0, 3.0, 4.0 };
float weight[5] = { 0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541, 0.0162162162 };

anchors.fill: parent

uniform mat4 matrix;
uniform float scale;
attribute vec4 gl_Vertex;
attribute vec2 gl_MultiTexCoord0;
varying vec2 coord;
void main() {
coord = gl_MultiTexCoord0;
coord.x /= scale;
lowp vec4 vertex = gl_Vertex;
vertex.x *= scale;
gl_Position = matrix * vertex;
}"
varying vec2 coord;
uniform sampler2D src;
uniform float qt_Opacity;
uniform float textureWidth;
uniform float offset[5];
uniform float weight[5];
void main() {
vec4 acc = texture2D(src, coord / textureWidth) * weight[0];
for (int i = 1; i < 5; i++)
{
acc += texture2D(src, coord + vec2(offset[i] / textureWidth, 0.0)) * weight[i];
acc += texture2D(src, coord - vec2(offset[i] / textureWidth, 0.0)) * weight[i];
}
gl_FragColor = acc;
}"
}
``````

Any comments are tips would be much appreciated!

hi,

i guess almost everybody makes this mistake at least once in the fragment shader …

you are adding 5*2 values that you took from the texture, that leads to the fact taht you properbly get a value greater than 1 for RGB … and 1 is withe…
vals: 0.3 + 0.4 + 0.2 + 0.35 + 0.26 = 1,51 << very withe

try to devide the result by 5*2 ore to use a mix() function from GLSL… than you get a propper result

maybe try:

``````                for (int i = 1; i < 5; i++)
{
acc += texture2D(src, coord + vec2(offset[i] / textureWidth, 0.0)) * weight[i];
acc += texture2D(src, coord - vec2(offset[i] / textureWidth, 0.0)) * weight[i];
}
gl_FragColor = acc / 10.0 ;
``````

cu
uwi