I wanted to know how I can make this foggy effect on the background just like in the image below, that the far parts are hidden by the fog.
Thank you.
Another option is to surround your scene with a cube and give it a Volume based on a Volume Scatter node, with it's density controlled by the Z-Depth or View Distance output of a Camera Data node. In the example below, I used "multiply", as this gives the best generalized effect, whereas, "add" will make the fog "fill in" the caverns as the camera scrolls out. Have a try with both if you like.
This is the scene in solid mode:
As you can see, all I did was surround the scene with a cube, remove the surface color from the cube, and connect the Volume Scatter with a low density (governed by the Math nodes)
You can achieve this effect using a Mist Pass in the compositor. Search on this site for "Mist Pass" and you should find many examples.