Looking to add fog to your scene? Fog is a great post processing effect that you can use in your game. But it has its limitations. In this tutorial, we will see how to add fog to your scene and also the Pros and Cons of Fog.
Adding Fog based on Camera depth
- Go to Window>Rendering>Lighting.
- Select the environment tab.
- Go to other settings.
- Check the Fog check box.
Now you should see Fog in your game scene.
It’s that easy but there are some issues with this
- Fog is a little buggy with URP. You need to play around with the settings to get the right fog.
- Fog is based on camera depth. If you need a particular place to be covered with fog then you have to use volumetric fog.
Here is how the basic fog in Unity looks like
Adding volumetric fog in Unity
Volumetric fog is not supported in URP out of the box. You will need to create fog using particles which we will cover in a different post. If you are using HDRP you can add volumetric fog with the steps below. Read more on URP vs HDRP.
- Add a Sky and Fog volume object to your scene.
- Add a collider to the game object to define the boundaries.
- Set the mode to local in the volume properties if you want fog in a localized area.
- Scroll down to the Fog component and check the Volumetric fog.
- Set the color and distance.
- Set the blend distance to tell Unity when the fog should start affecting the camera.
That’s it your volumetric fog is ready.