Learning Unity — Getting Started With Post-Processing In Unity
In the last article, we made our first introduction to the topic of post-processing in Unity. In this article, we are actually going to get our hands dirty and start learning how to actually make use of post-processing in Unity.
Unlike with previous subjects, with post-processing we can’t just jump into the Unity Editor and get started. To work with post-processing, we need to first install an additional package to our Unity project.
We can install packages by finding the Window menu and selecting Package Manager. Within the Package Manager window, find the Post Processing package in the list of options. After that, find the Install button in the lower right and click it. Installing the Post Processing package will take a bit of time.
Once it has installed, we can close the Package Manager window.
The next step is to create a post-processing profile. To do this, we need to create an empty object in our scene. Once it is created, we can then add a new component to this empty object — Post-Process Volume.
The Post-Process Volume component allows us to determine how much of a scene to affect with a post-processing effect. However, even if we want to apply post-processing to the entire scene we still need an object with the Post-Process Volume component.
For this example, we do want to apply the post-processing to the entire scene, but we need to configure the Post-Process Volume component to do so. This can be done by checking the box of the Is Global option in the component.
Notice the message we’re getting in this component now. We can see that we will require a post-process profile to continue. Fortunately, Unity is telling us exactly what we need to do. Follow the directions provided to generate a profile.
Now that we have a post-process profile and post-process volume, we can now actually add post-processing effects to our scene. Click the Add effect… button to receive a drop down menu of potential effects. All effects added will become part of the Post-Process Volume component that they were added to. If any adjustments need to be made to an effect, their settings can be found in the Post-Process Volume.
Now let’s see an example of what post-processing is capable of. I have a sprite that looks like a view from outer space. It has been added to my scene to act as a background visual. Here is how it looks in-game with no post-processing effects:
Now, within the post-process volume, I use the Unity Editor interface to add a Bloom effect. This is how our Post-Process Volume component appears after adding the Bloom effect:
Once we have an effect, we can turn on settings of that effect selectively and alter the values. In my example, I am switching on the Intensity and Threshold options, and then changing their values from 0 and 1 to 40 and 0.1 respectively. This is the result:
Quite a difference! With the Unity post-processing features, we can make our effects as subtle or glaring as we wish. We can also stack other effects to get the visual style we desire for our games.
And that concludes our first effort working with Unity post-processing. In the next article, we’ll begin learning about how to work with audio in Unity. Until then, good luck and happy coding!