UI Blur - URP
On this page
Introduction
Welcome to the UI BLUR - URP Shader documentation. This guide will help you understand how to integrate and utilize the UI Blur shader within Unity’s Universal Render Pipeline (URP) to create stunning blur effects on UI elements and 3D objects.
Overview
The UI BLUR - URP shader is designed to provide blur effects for both UI elements and 3D/2D objects within your Unity project. It includes:
-
ui_blur_mat
: A material for blurring UI elements and 3D/2D objects. -
ui_blur_mat_transparent
: A material specifically for blurring 3D/2D objects. -
UI Blur Controller
script: A utility to control the blur amount dynamically.
Setting Up the Shader (For ui_blur_mat
)
Enabling Opaque Texture
For the ui_blur_mat
material to work correctly, you need to enable the Opaque Texture property in the Render Pipeline Asset.
-
Open your URP settings.
-
Set Opaque Texture to TRUE.
Configuring Opaque Downsampling
It is recommended to configure Opaque Downsampling to 4x Box
for optimal performance.
-
In URP settings, find the Opaque Downsampling option.
-
Set it to
4x Box
.
Working with UI Blur Materials
ui_blur_mat
This material works for both UI elements and gameobjects in the scene.
-
Ensure the Opaque Texture property is enabled.
-
Apply the
ui_blur_mat
to your UI element or gameobject.
Make sure you turn off the Is Transparent
option in UI Blur Controller
.
ui_blur_mat_transparent
This material works specifically for gameobjects in the scene.
-
Create a second camera in the scene derived from the MainCamera.
-
Turn off the UI option in the Culling Mask for the second camera.
-
Apply the
ui_blur_mat_transparent
to your gameobject.
Make sure you turn on the Is Transparent
option in UI Blur Controller
and Blur Camera
property is set.
Using the UI Blur Controller Script
The UI Blur Controller
script allows you to dynamically control the blur amount.
-
Attach the
UI Blur Controller
script to the UI element or gameobject. -
Use the
BlurAmount
attribute to adjust the blur amount as needed.
Shapes and Customization
The package includes two shapes: a circle and a square. You can also use your own custom shapes.
-
Import your custom shape into the project.
-
Apply the
ui_blur_mat
orui_blur_mat_transparent
material to your custom shape.
New Feature: Drag-and-Drop UI Element Blurring
The new feature allows you to select specific UI elements that will be affected by blur for the ui_blur_mat
material using a drag-and-drop interface. Here’s how to use it:
-
In the UI Blur Controller inspector, you’ll see a Foldout labeled “UI Elements”.
-
Drag and drop UI elements from the hierarchy into this list.
-
Next to each added element, there is an option to Include Children.
-
If checked, all child objects will also be blurred.
-
If unchecked, only the parent object will be affected by the blur.
-
-
A cross
(X)
button next to each UI element allows you to remove it from the list.
FAQ
Can I use this shader with the Built-in Render Pipeline?
No, this shader is designed specifically for the Universal Render Pipeline (URP).
How do I control the blur amount dynamically?
Use the UI Blur Controller
script attached to the UI element or gameobject.