8 min read

Solid color and gradient vector objects can only get us so far when trying to create realistic shading and other complex effects. SVG filters give us the ability to achieve such effects on vector objects by combining various filter primitives.

Inkscape comes with many different preset filters (all listed under the Filters menu) we can use straight away, although a few tweaks might be necessary to produce the intended result. This article will show us how to make those tweaks on some of the filters, and in the final recipe, we will create our very own filter.

Due to a large number of filters available, trying to find the one closest to our needs using a trial and error process can be time-consuming. To compare all the filter outcomes on the same object you can open the filters.svg file that comes with your Inkscape installation in the share/examples folder. When testing filters, be sure to use objects having strokes, gradient fills, and transparency as specimens, as some filters produce varying results depending on the object’s attributes.

Filter rendering is quite CPU intensive and once they stack up they can reduce the Canvas update rate, so you might want to disable them temporarily by selecting the Menu | View | Display Mode | No filters mode, if you need to concentrate on another part of the drawing. To remove all filters from an object, select it and choose Menu | Filters | Remove Filters.

Blurring

The blur effect is versatile and has many possible applications in the realm of vector graphics. It is frequently used to enhance depth perception in a drawing, and to make certain elements stand out. It has its own section in the Inkscape menu (Menu | Filters | Blurs), where you will find several filter presets with descriptive names, such as “Apparition” and “Noisy”. These presets combine different effects to produce a particular blur, and can be modified using the Filter Editor.

This recipe will show us how to use the Gaussian Blur filter and introduce us to some basic filters related options.

How to do it…

The following steps will demonstrate how to use Blurs:

  1. Select the Ellipse tool (F5 or E) and create an ellipse inside the page area. Set its fill to Lime (#00FF00), stroke to Green (#008000), and stroke width to 32.
  2. Open the Fill and Stroke dialog (Shift + Ctrl + F) and increase the blur to 7 using the Blur: slider. Notice how the edges of the ellipse (outside edge and the one between the fill and the stroke) get more and more blurred, and how the object bounding box is now larger.
  3. Open the Filter Editor by going to Filters | Filter Editor…. Notice that there is one filter listed in the Filter list. This is the blur filter applied to the ellipse, and under Effect there is one filter primitive, namely Gaussian Blur.

    Sometimes the filter selection in the Filter list isn’t updated automatically, to refresh it simply deselect the object (Esc) and select it again.

  4. Under the Effect parameters tab make sure that the Link under Standard Deviation: is pressed and move the top slider to the right until you reach 25. Notice how the blur of the ellipse changes as the slider is moved, and also notice how the Blur: slider in the Fill and Stroke dialog changes with it (it will end up on 12.5). The object bounding box changes too.
  5. Press the Link button to unlink the X from the Y standard deviation slider and change the second (Y) slider to 0 to only blur the object in the X direction.
  6. Select the Filter General Settings tab and change the X box of the Coordinates: to 0.2 and the Y to 0.25. Set X box of the Dimensions: to 0.6 and the Y box to 0.5. Notice how the object gets clipped as we change the settings.

    Inkscape: SVG Filter Effects

How it works…

We can apply the Blur filter to the currently selected object by using the slider in the Fill and Stroke dialog (Blend can also be applied to layers). If we want to apply blurring through the Filter Editor we can use the Simple blur that can be accessed from the menu, under the Filters | ABCs category.

The Blur: slider is actually the standard deviation property of the blur although the scale is doubled. Changing one automatically updates the value of the other.

If we want to apply a more complex blurring effect we have to open the Filter Editor and unlink the X and Y standard deviation options.

The size of the filter region is a common setting to all filters and is defined by the Dimensions parameters in the Filter General Settings tab found in the Filter Editor. It is obvious from our blur example how the filter region needs to be larger than the original object size to avoid clipping at the original bounding box edges and get the expected result. A predefined, finite region is necessary because the standard deviation function is calculated using an infinite plane, which is both impractical and unnecessary in this context.

A more “natural selection”
Selecting filtered objects using the rubber-band selection is a hit-and-miss affair because the bounding boxes are usually larger compared to the unfiltered state. Another way of selecting can be very helpful in that case. First empty your selection in case you have anything selected (Esc), hold Alt, and start dragging over the objects you want selected. A red line appears when we start dragging and all objects it touches are selected. The selection must be empty otherwise Alt triggers the movement of the selection. The Shift key can also come in handy to add any objects we missed.

Using the Blur: slider in the Fill and Stroke dialog adjusts the filter region automatically so the object isn’t clipped at any side. If we want to change the region manually we can do so through the Filter Editor.

Having only one filter primitive inside the filter structure makes it the simplest filter we’ll encounter. More complex filters consist of more than one filter primitive and those primitives are usually of different types.

There’s more…

Many different blur presets are present in the Blurs section, such as Motion blur, horizontal and Motion blur, vertical, which we learned how to do manually. Using the presets can be a bit quicker but they always apply the same amount of blurring so if it doesn’t turn out to be the right amount you will need to adjust that manually.

A lot of filters from other categories also use the Gaussian Blur filter primitive as part of their structure and although most of them can’t be labeled as blur effects some could easily be listed under the Blurs category. Examples are the Feather filter under the ABCs category, Soft colors under the Color category that produces the well-known Ortoneffect, used in photo manipulation to produce hazy, dreamlike landscapes, Soft focus lens under Image effects, and Fuzzy Glow under Shadows and Glows.

Creating irregular edges using filters

In this recipe we will create a sheet of paper with burnt edges, using the Roughen and Blur content filters.

How to do it…

The following steps will demonstrate how to create burnt paper edges:

  1. Select the Rectangle tool (F4 or R) and create a 400×500 px rectangle. Set its fill to #fff7d5ff, stroke to #2b1100, and stroke width to 16.
  2. Apply the Roughen filter by going to Filters | ABCs | Roughen. Notice how all the edges (outside edge and the one between the fill and the stroke) turned irregular.
  3. Now all that’s left is to blur the edge between the fill and the stroke, which can be done by going to Filters | Blurs | Blur content.
  4. Change the stroke width to 8.
  5. Open Filter Editor, select the Turbulence primitive from the Effect list, change the Type: to Fractal Noise, and change the Base Frequency: to 0.025.
  6. Select the Displacement Map primitive from the Effect list and change the Scale: slider to 30. We now have our burnt sheet of paper.

    Inkscape: SVG Filter Effects

How it works…

Applying Roughen and Blur content brings us close to our goal but some tweaks to the filters are necessary. Since no clipping occurs when applying Roughen or Blur content we had to compensate by halving the stroke in this recipe.

The Turbulence filter primitive is used when our object has a property that is chaotic and random up to a point. It is often used when creating realistic textures. There are two types of Turbulence primitive filters and it can be hard sometimes to predict which one is better for our current case and it’s the same with a lot of settings. Try experimenting with the different options available before settling on one.

As you can guess from the name, the Displacement Map shifts parts of the object from their positions. Although this description is overly simplified we can deduce why its Scale: slide changes the object edges to be more or less irregular.

The amount of blurring we got using the Blur content filter seems to be right for our example. Else, we would be able to tweak the amount in the Gaussian Blur primitive.

There’s more…

Roughen isn’t the only filter that can be used to create irregular edges, but it proved itself as a good choice for the burnt paper edges look we expected to achieve. Most of the other filter presets that make the object edges irregular can be found under Distort, Protrusions, and Textures.

LEAVE A REPLY

Please enter your comment!
Please enter your name here