Applying a bigger blur radius using blur.glsl

edited January 2014 in GLSL / Shaders

Hello,

I was playing around with the BLUR GLSL shader example in Processing2.0, filed under 'Topics > Shaders > BlurFilter', and I'd like to know if there's anyway to increase the size of the blur filter. Specifying a parameter as we'd normally do for the default shader like, filter(BLUR,2); doesn't quite work for the 'blur.glsl' shader. This is my first time using shaders in Processing, and I apologize if this turns out to be a really silly question.

Is there anyway I could increase the size of the blur filter using the blur.glsl shader?

Thanks!

Tagged:

Answers

  • Hi, the blur size in the BlurFilter example is hard-coded inside the shader. You basically need to implement a larger kernel (this example uses a 3x3 kernel) in order to get a smoother result.

    Take a look at the SepBlur example, where you can control the extent of blurring with the blurSize and sigma parameters.

  • edited January 2014

    Thanks for the answer!

    Also, on a different note - I noticed that using filter(BLUR,amt); and filter(blur) in the draw() function work differently. The default renderer continuously blurs what's being drawn every frame, whereas with the GLSL shader, it appears to blur just once, and not every frame.

    The difference is that, if a rectangle is drawn to the screen, it eventually fades into the background if blurred using the default renderer, and with a GLSL shader in the draw() function, it just appears blurred and doesn't eventually fade away. Is this normal?

  • sorry I missed your last post. If understand your question correctly, I'd say that both filter functions operate in a similar way (by applying the filter on what has been drawn to the screen so far in the current frame), compare the output of these two sketches:

    void setup() {
      size(640, 360, P2D); 
      stroke(255, 0, 0);
      rectMode(CENTER);
    }
    
    void draw() {
      filter(BLUR, 1);  
      rect(mouseX, mouseY, 150, 150); 
      ellipse(mouseX, mouseY, 100, 100);
    }
    

    and

    PShader blur;
    
    void setup() {
      size(640, 360, P2D);
      blur = loadShader("blur.glsl"); 
      stroke(255, 0, 0);
      rectMode(CENTER);
    }
    
    void draw() {
      filter(blur);
      rect(mouseX, mouseY, 150, 150); 
      ellipse(mouseX, mouseY, 100, 100);
    }
    
Sign In or Register to comment.