Create a local fog effect
To create fog effects that global fog can't produce, use a Local Volumetric Fog component, which is a fog volume represented as an oriented bounding box.
Limitations
HDRP voxelizes Local Volumetric Fog at 64 or 128 slices along the camera's focal axis for better performance. This introduces the following limitations:
- No volumetric shadowing: Local Volumetric Fog does not reduce light intensity between a Light and a surface.
- Aliasing artifacts: Noticeable aliasing can appear at the fog volume boundary. Use Local Volumetric Fog with global fog and a Blend Distance above 0 to reduce edge hardness.
Create a Local Volumetric Fog component
Create a Local Volumetric Fog component in one of the following ways:
From the main menu, select GameObject > Rendering > Local Volumetric Fog.
Right-click in the Hierarchy window and select Volume > Local Volumetric Fog.
Set up volumetric fog
To use volumetric fog, enable it in the following locations:
Enable volumetric fog in Project Settings
To enable Volumetric Fog in the Project Settings window:
- Open the Project Settings window (menu: Edit > Project Settings).
- Go to Quality > HDRP > Lighting > Volumetrics and enable Volumetric Fog.
- Go to Graphics > Pipeline Specific Settings > HDRP.
- Under Frame Settings (Default Values) in the Camera section:
- Select Lighting.
- Enable Fog.
- Enable Volumetrics.
Enable volumetric fog in the HDRP asset
To enable Volumetric Fog in the HDRP Asset:
- In the Project window, select the HDRenderPipelineAsset to open it in the Inspector window.
- Go to Lighting > Volumetrics.
- Enable Volumetric Fog.
Enable Volumetric Fog in a global volume
To use Volumetric Fog in your scene, create a Global volume with a Fog Volume Override:
- Create a new GameObject (menu: GameObject > Create Empty).
- In the Inspector window, select Add Component.
- Enter “volume” in the search box.
- Select the Volume component.
- In Profile, select New to create a volume profile.
- Select Add Override.
- In the search box, select Fog.
To enable Volumetric Fog in the Fog Volume Override:
- Select the Fog dropdown.
- Enable State and Volumetric Fog.
Configure the fog with a mask
To configure fog color and density with a mask, use one of the following methods:
- Apply a 3D mask texture.
- Apply a Fog Volume shader graph.
Apply a 3D mask texture
A mask texture is a 3D texture that defines the shape and appearance of the local volumetric fog. Unity does not limit the size of this texture, and its size does not affect memory usage.
Create a mask texture
To create a 3D texture for a local volumetric fog component:
Create an RGBA flipbook texture in image-editing software.
For example, a texture size of 1024 x 32 represents a 3D texture size of 32 x 32 x 32, with 32 slices laid out sequentially.
Open the Local Volumetric Fog component and assign the 3D texture to the Texture field in the Mask Texture section.
Note: The Scale transform does not affect the fog size. To change the size, modify the Size value in the Local Volumetric Fog component.
Use a built-in mask texture
HDRP includes built-in 3D mask textures that set the density of a fog volume to different shapes and noise patterns. To use these textures:
- Open the Package Manager window (menu: Window > Package Management > Package Manager).
- Find the High Definition RP package.
- Open the Samples dropdown.
- Find Volumetric Samples and select Import.
Apply a Fog Volume shader graph
A Fog Volume shader graph is a custom shader graph designed to render volumetric fog effects in a 3D scene.
To apply a Fog Volume shader graph in a scene:
- Create and set up a Local Volumetric Fog component.
- In the Project window, right-click the Fog Volume shader graph asset and select Create > Material.
- In the Hierarchy window, select the Local Volumetric Fog GameObject.
- In the Inspector, set the Mask Mode to Material.
- In the Mask Material section, select the Material picker (⊙) and choose the Fog Volume material.