3D Level Design: Volumetric Fog in Unity’s HDRP
In this article, we are going to cover how to add volumetric fog using lights.
One approach is adding Fog to the Global Volume. This needs to be done by using the Fog Override and selecting ALL to turn on all of the properties.
The link to Unity’s documentation on those Fog properties can be found below.
The High Definition Render Pipeline (HDRP) implements a multi-layered fog composed of an exponential component, whose…
The Global Volume affects the camera wherever the camera is in the game scene, so this is great for outdoor scenes
My game scene is one room, so using a Global Fog Volume isn’t necessary. Instead, we can use a local Fog Volume or Density Volume.
A Local Volume affect the camera if they encapsulate the camera within the bounds of their collider.
We can create a Sky and Fog Volume or Box Volume.
You can adjust the boundaries of this volume by adjusting the Collider to fit the area.
Using the Sky and Fog Volume, it will automatically create a Visual Environment for the Sky, Physically Based Sky, and Fog overrides. For the Box Volume, it would just be Volume profile without any overrides.
Since the scene is indoors, we can have no sky and disable the Physically Based Sky so we are only left with fog. If you did the Box Volume, you would just need to add the Fog Override.
The Local Volume has the same Fog properties as the Global Volume. Since we are working in a smaller space, we want to reduce the Fog distance which will increase the density of the fog. The Color Mode either uses the Sky Color, which we do not have or a Constant Color, which you can pick.
Another way to add localized fog is using a Density Volume.
When creating a Density Volume, it make a game object that can be positioned throughout your game scene, just like the Local Volume.
The Density Volume dimensions can be adjust to fit the space you need the fog to appear.
You can chose the color of the fog using Single Scattering Albedo and the Fog Distance controls the density of the fog.
Density Volume works much like the Local Volume except for the ability to add Texture Mask for Density. The documentation for Density Volume and Texture Mask for Density can be found below.
Density Volume | High Definition RP | 7.1.8
You may want to have fog effects in your Scene that global fog can not produce by itself. In these cases you can use…
The fog may not be appearing because there needs to be light to interact with it. The HDRP simulates the interaction of lights with fog whether it is the Direction Light in the Global Fog Volume or a smaller light source in a Local or Density Fog Volume.
There are a few things in the HDRP settings that can be adjusted to increase the quality of the fog.
The first thing to check is the HDRP default settings, so if you cannot find it in the project folders go to the Project Settings.
Under graphics, click on the asset and it will bring it up in the project folder.
In the Asset settings, make sure Volumetric is enabled and if there is a High Quality option underneath make sure to enable that too.
Another way to fix fog issues is if you are using a Local Volume, there are addition options in the drop down. These options are not available in a Density Volume.
When you click on the Gear icon in the Fog Override, you have the option to select the Quality of the Fog. Also, if there is a Filter option you will want to enable that too.
The image on the left shows the Fog Quality is set to Low. You can see it is not a smooth and is wispy compared to the image on the right that the Fog Quality is set to High.
The last fix is to prevent Ghosting. Ghosting is when there is a residue print of light when it is moved making it look like there is a ghost. To prevent this, go into Project Settings then HDRP Default Settings, where you want to disable Reprojection under Volumetrics.