Blur Effects
Overview
The BlurEffect component included with Nova is the simplest way to add gaussian-style blur effects (as well as optional color filters) to your Nova-built UI. The single component can be used to create background blurs, layer blurs, frosted glass effects, and more!
Note
Any texture used as an InputTexture on a BlurEffect is not modified nor written to by the BlurEffect component. This means it's safe to use a given InputTexture object across multiple BlurEffects and in other stages of your render pipeline.
Background Blur
At a high level, achieving a blurred background effect simply requires:
- Providing an
InputTexturecontaining the content of the "background" you wish to blur to theBlurEffect- Note that the
InputTextureaspect ratio should match that of the camera rendering the UI (i.e., the camera that renders the UIBlock2D attached to theBlurEffect)
- Note that the
- Setting the
BlurModeon theBlurEffectcomponent toBackgroundBlur
For scenarios where the desired blurred background content is dynamic (e.g. some animating characters or objects in the game), the content can be rendered by a camera into a RenderTexture, and then that RenderTexture can be used as the InputTexture on the BlurEffect component.
Background Blur Group
BackgroundBlurGroup is a utility component included in the asset aimed at simplifying the described camera + RenderTexture configuration. On each frame the background content should update, the BackgroundBlurGroup will:
- Tell the
BackgroundCamerato render the scene to aRenderTexture - Tell its
BlurEffectsto apply their blur and color filters to the newly rendered image.
Layer Blur
LayerBlur mode provides the option to utilize the same blur and color filters as BackgroundBlur in scenarios where it's unnecessary or undesired to crop and align the OutputTexture to the camera viewport.
While in LayerBlur mode, the UVScale and CenterUV on the attached UIBlock2D will not be changed by the BlurEffect component, allowing it to be used in conjunction with Envelope, Fit, and other image scale modes.
Performance
While Nova is pleased to deliver a high-fidelity blur solution capable of running smoothly across all Nova-supported platforms and devices, blurring is a computationally-expensive process (relatively speaking) any way you slice it. Using the feature excessively or without consideration could noticeably impact an application's framerate. For this reason, Nova exposes a number of parameters on both the BlurEffect and BackgroundBlurGroup users can tune to further optimize the effect for their project's target platforms.
Broadly speaking, some key ways to reduce work when using BlurEffects are:
- Minimize the number of pixels and draw calls rendered by any background cameras (e.g. increase
RenderDownscaleFactoron theBackgroundBlurGroup) - Minimize the number of pixels processed by any
BlurEffect(e.g. reduceInputTextureresolution and/or increaseBlurDownscaleFactor) - Minimize frequency of rendering any background cameras (e.g. increase
RenderFrameIntervalon theBackgroundBlurGroup) - Minimize frequency of reblurring an
InputTexture(e.g. increaseBlurFrameIntervalon theBlurEffect)
Each increment of a downscale factor on both BlurEffect and BackgroundBlurGroup will reduce the number of processed pixels by 75%.
For example:
- Say the main camera renders at 1920x1080
BackgroundBlurGroupwith aRenderDownscaleFactorof1will configure theBackgroundCamerato render at (1920/2)x(1080/2), which is 960x540 (1/4th the pixels of 1920x1080), and will assign that rendered texture as theInputTextureofBlurEffectBlurEffectwith aBlurDownscaleFactorof1will copy theInputTextureto a temporary texture with a resolution of (960/2)x(540/2), which is 480x270 (1/4th the pixels of 960x540 and 1/16th the pixels of 1920x1080), and then will use that temporary lower-res texture in the blur algorithm.
As the BlurRadius on the BlurEffect increases, the reduced resolution from the background camera and temporary blur textures will become nearly imperceptible in the final blurred image, so adjusting the downscale factors is a simple path to massive perf-savings.
Note
There are other ways of acquiring already-rendered scene content across Unity's various render pipelines (e.g. Built-In, URP, HDRP), some of which may be more optimal than using an additional camera within a given scene or project. BackgroundBlurGroup is not a required piece of the BlurEffect system, so users looking to bypass the Nova-provided component in order to squeeze even more performance out of their background blur setups are welcome to explore or implement such alternatives and can continue to leverage all the BlurEffect functionality!