This is a shader I wrote, with help, that determines the amount of fog between the top of the fog layer and the ground beneath using the z-buffer. It then applies alpha to the fog based on that amount. The shader also supports fog holes where you can use a heighfield that will reduce the fog based on the image. It uses parallax mapping to give the appearance of a 3D fog basin.
The fog is less nearer the bottom of the screen because of the camera angle. It is also less around the rocks because it is closer to the ground there.
The fog does not clip the rocks because of this technique.