In this tutorial, I want to talk about the possibility of using Blender's procedural textures to modify Mist and Depth information in Compositing, achieving effects like the one shown above: an animated patchy fog mask.
Video Transcript
Hello everyone! In this tutorial, I want to talk about the possibility of using Blender's procedural textures to modify Mist and Depth information in Compositing, achieving effects like the one shown above: an animated patchy fog mask.
Mist and Depth provide masks based on the distance of objects from the virtual camera. I extensively discussed their features in a tutorial I published just a few days ago.
Blender's procedural textures are three-dimensional, so you can move them or resize them horizontally, vertically, and even in depth. This applies, as we'll see, in Compositing too.
If we add a procedural texture, such as Clouds, to a project, we can also use this texture in post-production by using an Input Texture node in a Compositing window. By connecting the texture to the Viewer node, we can analyze its appearance in real-time in the backdrop of the window.

If we modify the Offset values (for shifting the Texture) or the Scale of the texture, we can observe the changes in the backdrop. In particular, adjusting the X values will result in horizontal transformations, while adjusting the Y values will lead to vertical transformations. Lastly, adjusting the Z values will cause transformations forward or backward relative to the camera.
We can also adjust the parameters specific to the textures in their respective tabs and view these changes in real-time in the backdrop. For example, we can modify parameters like Size or Type in the Clouds texture type.

Using the arrow keys or the tools in the Timeline, we can navigate between the various frames of the animation.
The texture won't be animated because none of its parameters are animated... but we can address this immediately.
To add a keyframe to a parameter, position the mouse over the parameter and press the I key, or right-click and choose Insert Keyframe from the menu that appears on the screen.

For instance, let's set a keyframe at the first frame with Size XYZ set to 1 in the Texture node. Then, go to frame 250, change the value of Size XYZ to 0.1, and insert a new keyframe.

If you notice that the transformations are very slow at the beginning and at the end of the animation while navigating the Timeline, this could be due to the interpolation performed by Blender, which you can adjust by acting on the keyframes in a Graph Editor window.

Now, the information coming from Depth and Mist can be used as masks to achieve various effects based on the distance of points from the virtual camera.
Similarly, the grayscale information of a procedural texture (which is 3D), can be used as a mask or as a factor to modulate a mask.
By multiplying a procedural texture in grayscale with the information coming from Depth or Mist, we can darken certain areas of that information, and these operations can be animated because it's possible to move, resize, and generally transform procedural textures, as we've seen... well: this is exactly what I did to create the animations I showed you at the beginning of this tutorial.

The renderings you saw were made using only the Mist channel; in fact, even though the effect is interesting, these are not the final renderings of the scene, but rather an analysis of the animated fog mask created with the parameters I set.
In the 3D scene, I set the Mist Start and Mist Depth values in such a way that the fog begins right in front of the virtual camera and reaches its maximum value (that is, the white mask), just beyond the farthest objects in the scene.
Let's analyze the node setup I used. The information output from Render Layers is Mist because what we saw is just the fog effect mask. Since we are using Mist, not Depth, the values are within the range from 0 to 1.
Now I'm showing you the information output from Mist, connected to the Viewer node without any modulation from the textures.

Mist is then sent to a Multiply node, which multiplies this information with a Clouds procedural texture.
The Offset XYZ parameters of the Clouds texture are animated: they provide the texture's movement, particularly horizontally and in depth.
In the first clip, the texture Size is set to 2, resulting in very large patches; that's why the effect is barely perceptible.

The product of multiplying these two pieces of information darkens the Mist information in patches, corresponding to the dark areas of the Clouds texture.
The intensity of the result can be modified in various ways; in my case, I opted to use an RGB Curves node.

The output of the RGB Curves is then multiplied (that is: darkened), with a Blend Texture, which provides a vertical gradient achieved by editing the Color Ramp of the texture. This aspect is worth dwelling on because it allows for further interesting customizations.

At the beginning of the tutorial, I showed you two different animations.
In both cases, the node setup was the same, but the parameters that varied were the Offset XYZ of the Clouds Texture (which therefore regulates the speed of the movement), the Size parameter of the Clouds Texture (which regulates the density of the effect), and, above all, the Color Ramp of the Blend Texture (which determines the area of application of the Clouds Texture to the Mist pass).
In particular, in the second case, I accentuated the granularity of the Clouds Texture by setting a lower Size value, making the effect more pronounced.

Additionally, I modified the Ramp of the Blend Texture to narrow the effect to a band, leaving the foreground and the sky portion free of fog.

The gradients of the Blend Texture can be modified with a nice degree of freedom by adjusting the Ramp, whose parameters can be animated by setting keyframes. This means that the appearance can vary over time.
Animating the parameters of the Blend Texture allows for fadings and other effects. In general, considering the multitude of combinable tools and animatable parameters available in Blender, you can see that the achievable effects are many.
What you've seen here is just a simple example of what can be done using procedural textures to modulate some effects in Compositing, both for creating animations and single images. The combinations and the settings depend on the purposes you want to achieve.
I hope this tutorial can be helpful to you! See you soon!