Flexible Blur URP


Flexible Blur is the most complete blur solution for URP UGUI. Made to be immediately and painlessly usable, but also giving you the power to tailor different approaches to fit your use case.


by Jeff Graw Assets


Price History +

Do you need a URP UGUI blur solutiuon that is performant, high fidelity, flexible, and hassle-free?


When I found myself in this position, the only solutions I could find were able to satisfy, at most, perhaps two of the above requirements a satisfactory level.


And so I wrote my own solution and Flexible Blur was born!


Flexible Blur does not constrain you to one particular way of doing things.


Other solutions either:


(1) Limit you to a single, fullscreen blur per camera that needs be shared across all the elements of a canvas. This limitation isn't always a bad tradeoff, but it's a trade-off that you are forced to work around. It can be performant when overhead is able be shared between many elements. But there are serious downsides too. Besides significant artistic constraints, any time there are only a few elements covering a small area, you end up doing far more work than necessary. Or,


(2) Handle each blurred element individually. The trade-offs are exactly the opposite of (1). You gain artistic flexibility and tend to get better performance when only need to blur a small region across a few elements. But when you have dozens of elements that all require blur, all the overhead and drawcalls can be crippling even on higher end hardware.


Enter Flexible Blur.


•By default, Flexible Blur works on individual elements. But it also gives you the ability to mark compatible elements as "batchable," so they can share overhead. You have the best of both worlds.


•While other solutions that work in the manner described in (1) might provide the option to only calculate blur for some rectangular portion of the screen (for example, if blurred elements will only show up on the lower half of the screen), even when Flexible Blur acts similarily for batched elements it automatically finds the smallest area needed to cover every element.


•A goal of Flexible Blur is to aggressively reduce performance impact whenever possible. Flexible Blur looks for situations where it doesn't need to work (blurs are all offscreen or inactive) and early outs. Reducing overhead in this way is especially useful in contexts where you would otherwise suffer compounding overhead (for example, a multi-camera setup with several layers of stacked blur).


•With Flexible Blur, you don't need to adapt your UI around the limitations of a blur solution. The blur solution will adapt to fit your UI.


•You have the option to use compute shaders. The compute shader path is appreciably faster on most hardware than traditional shaders, and can drastically reduce draw calls when you need multiple distinct blurs. (There is still some overhead, so while compute shaders reduce the use cases for batching, they don't eliminate it all together)


•You are able to create presets that react to the current quality level. This important feature appears missing in most other solutions. Blur is generally not the cheapest effect in either case, but there's a large performance difference between "good enough" blur and "beautiful, high fidelity" blur. Given the large disparities between hardware configurations, if you lack the ability to be responsive to quality level you either sacrifice quality on the altar of low end hardware, or low end performance on the altar of quality.


•Choice between UIBlur and UIBlurImage components. UIBlur is lightweight, writes directly to the camera target texture, but has fewer features. UIBlurImage reproduces all the features of standard Image components.


•Supports stacked blur (blurs that blur other blurs), both as a part of a multi-camera, multi-canvas setup, but also for blurs that share the same camera and canvas (with some limitations).


•Simpler setup than the popular alternatives. You do not need to add components to your Cameras, and you do not need to create materials for blurs. Applicable cameras only need the Flexible Blur Feature added to their Renderer.


•Supports dithering, to reduce banding on large blurs.


•Source code provided.


CAVEATS

  • Does not support built-in or HDRP render pipelines.
  • Does not yet support Unity 6 render graph, but support is planned in the near future.
  • VR support is still in development and has not been extensively tested. Currently only supports multi-pass. The compute shader path is not yet supported in VR.
  • As opposed to other assets, will not make the claim that Flexible Blur is "the fastest UI blur solution on the asset store." It certainly is the fastest solution for a large number of scenarios, but it's not going to be fastest in every situation.
    • Flexible Blur provides a superset of the functionality of other solutions, which means that the subset of features that corresponds to a competitor may be less optimized, and that's the cost of flexibility. This isn't to say that Flexible Blur will necessarily be slower when limited to the best case scenario of some other asset (especially if that other asset does not use compute shaders), but rather that everything else being equal, if I were to write a solution with more limited functionality, I would expect that to excel inside its niche relative to a solution that enjoys a wider scope.
    • What Flexible Blur uniquely provides is the tools you need to agressively optimize for just about every situation. You should be able to target just about any sort of device. The fine grained control over blur properties generally makes it easier to balance performance and fidelity.