Skip to content
Commit c16b31e5 authored by Neil Roberts's avatar Neil Roberts
Browse files

blur-effect: Use a gaussian blur

This replaces the 3x3 box blur of ClutterBlurEffect with a two-pass
gaussian blur. The sigma value for the gaussian function (ie, the
bluriness) can be adjusted with a property. The radius for sampling is
limited to ⌈6σ⌉×⌈6σ⌉ as suggested by Wikipedia. The factors for the
sampling are stored in an array in a uniform so the effect only needs
to switch shaders when the sigma jumps to the next radius size. This
makes it feasible to animate the bluriness without depending on
conditional jumps in the shader.

The effect creates a second texture at the same size as the
offscreen's texture to implement the second pass. The effect avoids
redrawing the first pass if the actor is redrawn without being
dirtied. However if the sigma value changes it does need to redraw
both passes but it can still avoid repainting the actual actor.

The two passes share a single shader program with a uniform to
change the direction. The pipelines for each radius are cached in a
hash table attached to the class struct so they can be shared across
multiple instances of the effect.
parent 03f4f1c6
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment