Learn how we can do a Camera Blur in Unity for Built-in Render Pipeline using the Standard Gauss Method.
Searching Camera Blur Shader for Unity has been always a hectic task for Game Developers. And it becomes more ruthless if we are searching for Unity’s Built-in Render Pipeline. Though we might get Shaders easily for URP and HDRP but getting a good Blur Shader for Mobile and a good Blur Shader for Unity has always been a tasking work. So today we will see how we can do a Camera Blur in Unity which is also optimized to work well with mobile devices.
Camera Blur Shader
Before we begin the process let’s first get the Camera Blur Shader for Unity from the Asset page.
Get Unity Blur Shader.
Once you get the Unity Blur Shader project from the Asset page, extract it and open the Unity Scene. You can check the use of Unity Blur Shader and take reference from it. But for now, let’s replicate the process from scratch.
1. To begin with the Unity Blur Shader and Camera Blur, first, create a new scene where you want to have a Blur effect. Also, add a Sprite Renderer with a BG Sprite to the Scene to visualize the effect. You can find a BG Image in the Project Folder or you can use your own custom image. If you are using the BG Image available on the project file then don’t forget to scale it down to fit inside a 16:9 Camera view.
2. Now click on the Camera Game object present in the Hierarchy to open up the Inspector. From the project view, locate the Blur Script from the Scripts Folder present in “VOiD1 Gaming – Unity Blur Shader”. And then, drag and drop the Blur Script to the Camera Game Object Inspector. Alternatively, you can also press the Add component button in the Camera Game Object Inspector and use the Blur Script. You will notice the Camera in the Game View goes black, but no need to worry, we will fix it in the next step.
3. Now as you can see the Blur Script requires two fields, Shader and the Material. Just grab the Unity Blur Shader available on the Shader folder and also get the Unity Blur Material from the Material Folder present in “VOiD1 Gaming – Unity Blur Shader”.
4. Once the Shader and the Material are provided, you can see that the results are visible in the Game View. Our Camera Blur is working super fine and now all we need to do is tweaking the sliders to get some custom effects.
5. There are 3 Sliders that manipulate the way of Blur - Radius, Quality Iterations, and Filter. Radius is the radial distance covered by the algorithm to sample it for Blur calculation. Increasing the radius will increase the distance of the blur strength. Quality Iteration is basically the number of Blur iteration calculation done to improve the quality and the smoothness of the blur. Increasing the quality iteration will increase the amount of blur by recalculating the current blur amount and adding the blur over it again. Lastly, the Filter, Down-samples the image effectively increasing the blur strength without increasing the radius and makes the blur smoother.
So, as you can see, within 5 steps we added Camera Blur to our scene. This Unity Blur Shader is well optimized for mobiles so that you can use it for a wide range of mobile devices.
Comments