A screen blur effect for Unity/C#
Asset Store Link
HRP version
non-ShaderGraph version
© 2022 Justin Garza
PLEASE LEAVE A REVIEW OR RATE THE PACKAGE IF YOU FIND IT USEFUL! Enjoy! :)
- GaussianBlur_URP
- Table of Contents
- Contact
- Terms of Use
- Description Features
- Set Up
- Set Up (for Transparent objects)
- GaussianBlur_IU
- GaussianBlur_IUEffect
- GaussianBlur_WS
- Demo_AdvancedUI_1.0 and Demo_AdvancedUI_2.0
- Videos
- FAQs
My Contact info is on my github profile
https://github.com/jgarza9788
Required: please follow Unity's EULA
Suggestion/Optional: please put my name in the credits, or in the special thanks section. :)
- Alpha Mask
- Mobile Friendly
- Adjust Blur, Lightness, Saturation, and TintColor
- Built on URP
- easily modifiable/editable Shader Graph
- 3 Shaders
- GaussianBlur_IU
- GaussianBlur_IUEffect
- GaussianBlur_WS (WorldSpace, or Objects)
You need to set up your project to use a URP Asset.
- You can use the URP_Asset i provided (in *\GaussianBlur_URP\Assets\URP) and change the camera settings
- Project Settings
- Camera Settings
Note: you might need to make your own URP_Asset if there is not one that matches the unity version.
- right click -> Create -> Rendering -> URP Asset (with Universal Renderer)
- if you use your own check ✅ "Opaque Texture"
Image Link- if you are making a mobile game consider changing the "opaque Downsampling" option.
Note:
"Opaque Texture" gives us the ability to access _CameraOpaqueTexture, a texture of what the main camera sees (but this texture will not have transparent objects (like Sprites) within it)
if you need sprites and non-opaque to show up in the blur, please see the Demo_Basic(Sprites).scene
- the RTCamera outputs an image to a RenderTexture
- (most of the time you'll want this to view exactly what the main Camera sees)
- the Shader uses the RenderTexture as the based image for the blur.
You can actual use nearly any image you want.
So if you don't want to use a second camera, consider a static image.
In addition, you can change the Size and Color Format of your RenderTexture.
reducing the size and optimizing it.
To use the shader on the UI, just use the material.
(or create you're own material and use my shader)
CustomTexture:
pass in any texture (image) you'd like (i.e. a Render Texture or 2D Texture)
useCameraOpaqueTexture:
this will be used as a default texture for blurring.
note: this will not render transparent (Sprite and non-Opaque) objects (you might want to use a Render Texture)
- see Set Up (for Transparent objects) section above
BlurScale:
This is how much to blur the texture.
(This will automatically adjust two other variables)
Lightness:
how light or dark the UI should be.
Tint:
a color tint to be applied to the UI.
Saturation:
adjusts the saturation (color) of the UI.
This will use the Source Image.
So you can fade the blur depending on where it is on the screen.
see Demo_UIEffect.scene:
The Source Image is our map to know how much to blur the edges and the center.
This is for Objects in the WorldSpace.
see Demo_3DModel.scene for an example.
note:
The Layer should be set to BlurObject.
Metallic & Smoothness:
these are used to adjust the shinny-ness of the object.
if this is not working we might want to double check our custom-renderer. it's in *\GaussianBlur_URP\Assets\URP
Here are the settings for the custom-renderer.
- we filter out the Layer "BlurObject"
- because we do not want the camera to render it.
- we create a render feature to add the BlurObject back into the final image after being rendered my the GaussianBlur_WS material.
these scenes shows how we can blur only a piece of the image.
In the ShaderGraph we are creating a mask.
we are controlling the about of blur and other items with shader properties and Animator Component.
these videos go in deal on how the ShaderGraphs work.
please watch these if you plan to create your own remix of the shader.
GaussianBlur_UI Video
GaussianBlur_WS Video
GaussianBlur_UIEffect Video
by default by Shader will be using the _CameraOpaqueTexture, this texture only contains Opaque Objects. However we can use whatever Texture we want.
please read the Set Up (for Transparent objects) section above.
Most of the time this is just caused by the settings in the URP_Asset or the settings you picked in the shader.
please review the settings and make sure they are ok.
Try re-downloading the asset and/or Contact me for help.
Try deleting the Asset\Settings folder.
This folder was created when the URP project was created.
I'm not sure why this causes an issue with the project,
but it fixes the project sometimes.
this asset can be adjusted for multiple Blur Layers, however there are a few issues with adjusting this asset for Blurred Layers.
- i like to keep this asset simple enough so most people can easily use it.
- multiple blur layers can be very taxing on the CPU/GPU
- we would need to have multiple cameras, render textures, etc (one for each layer) or have a special shader to merge and blur each.
- use Vulkan
- this should be in the PlayerSettings, Other Settings, Rendering.
- DownSampling
- you can also change the "Opaque Downsampling" option in the URP_Asset.
- reduce the size and color format of the render texture.