Page MenuHome

BoxBlur shader stop working in certain Bl version.
Closed, ArchivedPublic


System Information
Debian 9 x64, nVidia GT620

Blender Version
Broken: 2.76 (from web)
Worked: 2.75a (from web)

Short description of error
This is a Filter 2D download from doesn't-know-where (I couldn't find source). It is a Blur filter with amount and multiplier values. It works pretty well in 2.75a. Since 2.76, it doesn't work anymore, the output is only a bit darker. No blur.

Shader code is:

/* Simple Box Blur
 * Higher amount = slower
 * multipler property does not affect performance

uniform sampler2D bgl_RenderedTexture;
uniform float bgl_RenderedTextureWidth;
uniform float bgl_RenderedTextureHeight;
uniform float amount;
uniform float multiplier;

vec2 pix = vec2(1.0 / bgl_RenderedTextureWidth, 1.0 / bgl_RenderedTextureHeight) * multiplier;

void main() {
	vec4 sum = vec4(0);
	int i, j;
	for(i = -amount; i <= amount; i++){
		for(j = -amount; j <= amount; j++){
			sum += texture2D(bgl_RenderedTexture, gl_TexCoord[0].st + vec2(float(i), float(j)) * pix);
	gl_FragColor = sum / pow((amount + 1) * 2, 2);

Exact steps for others to reproduce the error
Open file with 2.75a, run Game.
Open file with 2.76, run Game.



Event Timeline

Sergey Sharybin (sergey) closed this task as Archived.Sep 11 2017, 1:11 PM
Sergey Sharybin (sergey) claimed this task.

Your uniform value for amount is set as float in shader, but declared as integer in camera properties. Now, thing is, before 2.76 (commit rB97b431e4) all shader uniforms were binding as floats, but it's not what you always want so proper int/float binding was implemented. What happens in your scene is that binding uniform fails because BGE tries to bind it as integer, while it is float in shader itself.

Unfortunately, we can't do-version anything here to avoid regression, such things would require writing comprehensive GLSL compiler by ourselves.. Two things you can do:

  • Change uniform float amount; to uniform int amount; in the shader itself
  • Change amoumt from integer to float in logic editor.

So thanks for the report, but it's not really a bug..

As the code is done, changing amount to float, it does weird results. "uniform int amout" is the real solution.

Anyway... by setting amount to 0 (no-blur), the result is darker than original. With 2 or 3, it has more or less the same brightness... I would like to fix it, but it is not a Blender bug, but this code bug. I will ask about it in IRC #gameblender.