All Questions

Community

Daniel Queiroz Porto
posted to: Gaussian blur

Is there a problem in including alpha in the blur calculations?

I was trying to blur only one "layer" on top of another background, so I set my viewports to transparent_bg and before the blur shader eveything was looking right. After the blur shader, the transparent parts got black, and the first thing I tried was to remove all the ".rgb" from the shader code to factor the alpha in and it worked.

But what was the reason for taking the alpha out in the first place? Is adding the alpha in too expensive for the effect?

  • Nathan Lovato replied
    Solution

    Adding the alpha isn't too expensive, it's just adding one multiplication per blur sample.

    The alpha channel is out in the tutorial because if you don't have a transparent image in the first place, you end up with ugly blurred transparent edges. So you need two blur shaders for transparent images and for non-transparent images.

  • Daniel Queiroz Porto replied

    Oh, nice! Glad to know! Thanks for the answer!