godot: 3.0 Shader Language: increments (++) does not work

Operating system or device, Godot version, GPU Model and driver (if graphics related): windows 64, 73132c9, nvidia

i was trying to implement blur shader today. editor crashed multiple times while i was writing this. and finally it doesn’t work (but works on shadertoy for example)

putting this on the Sprite (with standard icon as texture) and uncommenting last line will crash the editor. and there is while instead of for, because fors just don’t work (known issue tho). but why is it crashing the editor??? nothing is written into the console, so i have no idea what is happening.

shader_type canvas_item;

float SCurve (float x) {
    x = x * 2.0 - 1.0;
    return -x * abs(x) * 0.5 + x + 0.5;
    //return dot(vec3(-x, 2.0, 1.0 ),vec3(abs(x), x, 1.0)) * 0.5; // possibly faster version
}

vec4 BlurH (sampler2D source, vec2 size, vec2 uv, float radius) {
    if (radius >= 1.0) {
        vec4 A = vec4(0.0); 
        vec4 C = vec4(0.0); 
        float width = 1.0 / size.x;
        float divisor = 0.0; 
        float weight = 0.0;
        float radiusMultiplier = 1.0 / radius;
        float x = -radius;
        while (x <= radius) {
            A = texture(source, uv + vec2(x * width, 0.0));
            weight = SCurve(1.0 - (abs(x) * radiusMultiplier)); 
            C += A * weight; 
            divisor += weight;
            x++;
        }
        return vec4(C.r / divisor, C.g / divisor, C.b / divisor, 1.0);
    }
    return texture(source, uv);
}

void fragment() {
    //COLOR = BlurH(TEXTURE, vec2(64.0, 64.0), UV, 20.0); //crashes even with 2.0 radius
}

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

so the minimal code is now

shader_type canvas_item;

void fragment() {
	float i = 0;
	i++;
}

Lol, then this is probably a duplicate of #10560, as you’re creating an infinite loop… ^^

leaving the crash aside (need to check it)…

I was thinking of adding an option to the texture importer plugin to generate gaussian blurred mipmaps, this way you can blur sprites easily by just using textureLod()

On Sat, Aug 26, 2017 at 5:01 PM, Marc notifications@github.com wrote:

Is it freezing or crashing with “doesn’t respond”? Because, an insanely expensive shader can also look like a crash since it would slow down the editor enough to be frozen :p

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/10661#issuecomment-325158734, or mute the thread https://github.com/notifications/unsubscribe-auth/AF-Z22xr---X6QjqZH4kt3A662oc-Zchks5scHmWgaJpZM4PDjs- .