In this ninth and final episode of a series on Atmospheric Perspective in Compositing in Blender 4.1, we will add the virtual universe background to the setup and conclude the series.
Video Transcript
In this ninth and final episode of a series on Atmospheric Perspective in Compositing in Blender 4.1, we will add the virtual universe background to the setup and conclude the series.
The operations we have performed so far have also significantly affected the virtual universe background, especially in terms of desaturation, due to the extreme values present in the Depth mask corresponding to the background, which is at an infinite distance.

In the second episode of this series, I had you enable the Environment Render Pass before starting the rendering. The output of this Render Pass shows only the virtual universe in color, while all the objects present in the scene are black.

Therefore, we need to overlay the Environment Render Pass onto the rendering modified with various effects.
There are several ways to perform this operation.In my case, I chose to use a Z-Combine node, from the Color Mix group, immediately connecting its output to the Reroute node.

This node blends two images using their Z channels to determine which pixel is closer to the virtual camera.
Let's connect the output of the CONTRAST group to the first Image input of the Z-Combine node.
Then, let's connect the Environment Render Pass straight to the second Image input of the Z-Combine node.
Finally, let's connect the Normalize node to the first Z input of the Z-Combine node, leaving the second one empty.

Observing the setup, we notice that the Normalize node has 5 outgoing links, and the effects are implemented in succession.

Node groups can be nested.
All these elements (from Normalize to Z-Combine) can, in turn, be included in a single group called ATMOSPHERIC-PERSPECTIVE.

This group can then be inserted into other projects simply by appending the NodeTree present in this project.

I talked about appending Compositing Nodes Groups from other Blender projects in a videotutorial previously published on my channel.
In conclusion, we can use the Depth information to modify Saturation, Contrast, Blur, and Color Grading of the elements based on their distance.
Don't forget to activate the Environment Render Pass before rendering, so that you can isolate the background of the virtual universe and work only on the objects present in the scene before adding the background back at the end of the effects chain!
We have thus concluded this series of nine episodes on Atmospheric Perspective in Compositing in Blender 4.1. I hope the tutorials can be helpful to you! See you soon!