Optimizing StreamFX in your OBS Scenes

Blur and the common Pitalls

The Blur filter is a relatively simple case and one of the most common pitfalls as well. Solving many of the performance problems that comes from using it is also super easy and can be done in less than 30 minutes – so what are they?

Blur Masking vs Cropping

The biggest case for performance problems is apply a Blur filter to the entirety of the source, without applying a Crop/Pad filter first, and then relying on the Masking option to do it for you. The problem with this is that Masking runs after the blur happens, not before – it can’t reduce work that was already done.

When all you want to do is blur a small part of the screen, applying a blur filter to the entire thing is super wasteful. An alternative to this is to duplicate the source using Source Mirror, then apply a Crop/Pad filter, and then apply the Blur. This reduces the impact of blurring by a lot.

Note that applying a Crop/Pad after the Blur also acts the same as Masking does. The same applies to the cropping provided by the scene editor.

Wrong Blur Types for Large Size Blurs

But what if you do want to blur everything? In that case the above doesn’t help you, but you can help yourself in another way. Often there are more optimized variants of a blur available, which may reduce the impact by half or even more.

For example you can completely replace a Gaussian Area Blur with a Dual-Filtering Blur and the latter will be significantly faster. Just look at this table to see replacements that work up to 5 times faster on any hardware:

Original BlurReplacement BlurUp to x% faster
Box Area Blur
Box Directional Blur
Box Linear Area Blur
Box Linear Directional Blur
~200%
Gaussian Area BlurDual-Filtering Blur~500%
Gaussian Area Blur
Gaussian Directional Blur
Gaussian Linear Area Blur
Gaussian Linear Directional Blur
(Not identical to Gaussian Blur)
~200%
Possible replacement blurs that take siginificantly less CPU and GPU time.

Full Resolution Blurring is Wasteful

The final optimization you can do for your blurs is to scale the input to them down. This is a trick that Games and Web Browsers have been doing for years in order to do shadows, glows, and similar blur based effects in real time. As an example, let’s start with a 2560×1440 source that you want to blur with a 64px wide Box Area blur.

This is super expensive to do – even on modern hardware – and that’s never good for reaching a specific framerate target. But there’s something we can do: Downscaling! By putting a Scaling/Aspect Ratio filter before the Blur filter, setting it’s Scale Filtering to Bilinear and the size to 1280×720 (exactly 50% of the original) we can now reduce the blur size to just 32px.

warning

Gaussian Blur behaves differently!

At the time of writing this, Gaussian Blur requires that you slightly increase the Blur size from the halved value in order to get the same blur effect. For example, a downscaling 32px blur actually needs a blur size of 34 to 35px. This will probably be fixed in the future.

This can be repeated until you’re no longer happy with the blur quality – in my case I stop this at around 8px width. By doing this we can approach the time savings that Dual-Filtering allows us to do with any of the Area or Directional Blurs – as long as the direction is aligned with the pixel grid.

Bookmark the permalink.

Comments are closed.