Hey, this is a project I was working on where I wanted there to be a haze applied with Z-depth through the image, and I made use of Bartek's technique for producing a fine, anti-aliased render to generate the mist. However there was an extra layer of complexity here - I was using a transparent material (and a volumetric scatter material for the cloud, but that turned out to be a little less of a problem). I eventually worked out a solution, so I thought I'd share in case it inspired anyone else.
The trouble with applying the mist to a transparent material using the basic technique is that the mist is calculated by distance to the surface of the glass and no further - so when we apply the mist to the image, the parts of the distant elements only receive a low mist, not the higher levels of mist they get outside the glass, making them sharper and more saturated.
In order to solve this problem, I used the transmission rays (again, the glossy and diffuse channels would have been unhelpful here) through the glass material to allow the lighter colour from the distant channel to be refracted to wherever they appeared through the glass. (effectively adding the "is transmission ray" to "is camera ray" in the light paths recognised by the mist render layer).
However, because this renderlayer uses one material for all the elements in the scene, I needed to include the glass shader within the Z-depth material. For this, I set unique object index numbers for the glass and cloud (under the object info panel), and used the object info node to assign the glass shader. To avoid darkening the mist too much, I mixed it with a transparency shader using trial and error until it gave consistent results.
Similarly with the cloud, I mixed a holdout texture with a transparent shader to allow mist from the distant sky to bleed through the cloud.
Unlike Bartek, I used a sky from within blender, which may have caused more trouble than it was worth in the end. Firstly I used a plane (using a transparent shader in the main render, but using the emission shader in the mist render layer), positioned as far back in the render distance as I could. This allowed me to set a nominal mist value for the sky, but since I wanted to preserve the blue of the sky, I ran into aliasing problems between the tops of the mountains and the sky. I managed to eliminate this using a very carefully set up color ramp. The one major problem this caused was a slight reverse vignette effect, where the sky is lighter at the corners instead of darker, so I'm planning to cover that with a new vignette in photoshop.
Apologies for the crazy rambling description, but I thought the technique might be worth talking about.