Here are the steps to have volumetric fog (this was done with unity 2018.2.0f2, HDRP Template project and HDRP version 2.0.5-preview) :
-
Be sure to enable “Support Volumetrics” and optionally enable “Increase resolution of volumetrics” in your HDRP asset:
-
In the Volume Settings of your scene, add a “Volumetric Fog” and a “Volumetric Lighting Controller” component.
Change the “Fog Type” value of the “Visual Environment” to “Volumetric”.
-
You should already be able to see the volumetric fog in the scene and game view.
If it doesn’t show up in the scene view, check that the fog toggle is enabled in the scene view :

-
Note that by default, the fog density is very low. This is set by the “Mean Free Path” parameter : the lower the parameter, the higher is the density of the fog.
-
Now you can add a density volume object in your scene to control the fog density locally :

-
Here I added a blue fog with a point light inside in the scene :
Now for the density texture :
I modified the example script of texture 3D so that the generated texture can be use in a density volume. Here is my code :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Experimental.Rendering;
[RequireComponent(typeof(DensityVolume))]
public class Texture3DToDensityVolume : MonoBehaviour
{
Texture3D texture;
void Start ()
{
// The curent density volume texture size is hard coded to be 32
texture = CreateTexture3D (32);
DensityVolume densityVolume = GetComponent<DensityVolume>();
densityVolume.parameters.volumeMask = texture;
}
Texture3D CreateTexture3D (int size)
{
Color[] colorArray = new Color[size * size * size];
texture = new Texture3D (size, size, size, TextureFormat.Alpha8, true);
for (int x = 0; x < size; x++) {
for (int y = 0; y < size; y++) {
for (int z = 0; z < size; z++) {
// Calculate the radius
float f =Mathf.Sqrt(
Mathf.Pow( 2f * ( x - 0.5f*size ) / size, 2 ) +
Mathf.Pow( 2f * ( y - 0.5f*size ) / size, 2 ) +
Mathf.Pow( 2f * ( z - 0.5f*size ) / size, 2 )
);
// Fill pixels of radius <=1 with alpha = 1
f = (f <= 1f )? 1f : 0f;
Color c = new Color (1.0f, 1.0f, 1.0f, f);
colorArray[x + (y * size) + (z * size * size)] = c;
}
}
}
texture.SetPixels (colorArray);
texture.Apply ();
return texture;
}
}
As you can see, the texture format used has to be Alpha8, as we only need one channel to store the density multiplier.
Alternatively, you can create a static density 3D texture.
For the example, I used this texture, authored in photoshop :
It contains 32 slices of 32x32 pixels.
Import it using these settings :

Now, open the 3D texture creation tool:

Drop the texture in the texture field and hit “Generate 3D Texture”:

The newly created 3D texture is saved in the same folder as the original one, and ce be used in the density volume settings.
This one will render rings like this :
I hope that I covered the subject and that now you can enter the world of volumetrics 