How to make distance fog
Use the mist pass. You can enable it by going to the Layer Properties and under &quot;Passes&quot;, enable &quot;Mist&quot;. Then, in the camera settings, under &quot;Viewport Display&quot;, enable &quot;Mist&quot; so you can see where the mist begins and where it ends (the location where an object will be completely invisible, shrouded by mist). This can be adjusted in the World settings.
Now head to the compositor workspace and you will see a &quot;Mist&quot; output. Plug that into a coloramp. There you can adjust values, and clamp the pass as you want. It will make sense once you mix it with the output using a MixRGB set to &quot;Add&quot;.
Here is a very quick youtube video I found detailing the parts: https://www.youtube.com/watch?v=uXXYUv-793c