Fade to transparent via depth/mist? (on a static render)

Hi everybody,

So I’ve come across a problem I just cannot find an answer to, but I’m sure there’s something simple I’ve overlooked. I’m trying to make a group of objects fade to transparent the further into the distance they are, in a scene where the background is transparent. (Cycles render)

The image will then be placed on top of a separate layer in Photoshop, which is why the transparency is important. The scene I’ve made is at work and I’m unable to provide a .blend file or even show it (my company is very strict), but I’ve made an example of what I’m after using the standard blender cube set-up.

So this is the effect I’m looking for:

  1. http://rjanes.com/uploads/Box3.JPG
    (For this, I rendered the scene with the background transparent and then made the fading alpha effect in Photoshop. Not an ideal solution)

I think the solution has something to do with Mist? Here’s a render - without transparency - and a Mist Pass applied to the scene/camera.
2. http://rjanes.com/uploads/Box5.JPG

So, using transparency, I get an effect something like this.
3. http://rjanes.com/uploads/Box4.JPG

Is it possible to switch the red mist colour to transparency in Blender to end up with the effect in the first link?
I did try applying a mask by selecting all the red colours in Photoshop, but it produced undesirable results and is even less useful on a scene that contains lots of colours including red.

Thanks guys, this one has me stumped.

Attachments


Should be able to just invert the mist pass and copy it into the alpha channel. (Blender normally expects premultipled/associated alpha, so throw in an alpha convert node afterward to fix that. Just in case)


alpha_distance.blend (618 KB)

Thank you for this, J_the_Ninja. I’ll put it to the test on my work file at the first opportunity, but after having downloaded your file it looks to be exactly what I’m after. Cheers