Aerial perspective from Z-channel (or mask from color)



I’ve got Z channel and I want to composite aerial perspective from it (fake of course). I’ve loaded Z, inverted, added gamma and curve to adjust color then merged with main image. After inversion Z looks like front is black back is white.
All is fine exept blue-white fog is added to sky also.
Unfortunately renderer I’m using doesn’t provide alpha channel that’s why I have to “extract” mask from Z or Mat-ID channel (and most probably use it with merge node).
In photoshop I’ve been using action to remove white part of image and replaced with black then added “minimum” filter so border of mask is contracted a little to remove fog from sampled edges like trees.
In Krita there is simple filter color-to-alpha and that’s what I’m looking for in Natron.

Best regards.


I’ve found one solution but I’m sure there can be many others.
It will work much simpler if your fog is grayscale (just apply the color correction after all this stuff)

Let’s suppose you want to get rid of the pure white value and keep the rest. Put a seexpr _simple node after your inverted/gamma Z pass. And in the R field enter r<1 ,same for G and B fields .

That will create a black and white mask were all value below 1 get white ( True ) then you can merge it with the Zpass with a multiply operation.
Finally apply the blue tint and you’re good to go !


It look like it’s working also with a keyer in luminance mode with a very low Softness Lower value. And output mode set to Premultiplied. It’s less geeky , and also by tweaking the softness lower you can have more or less transitions.

The two methods don’t give the same result as color to alpha tho… It will get rid of the sky in the Z.


Thank you!
Second way with keyer is better IMO, more options to go. To get rid of bright edges I’ve added antialiasing filter and erode.


I’d like to share my version, using solid color node and masking:


Cool ! so many ways to do the same things :smiley:


This way it’s possible to easily control fog color so you can eyeball or pick it, and, what’s most important, fog replaces color via merge (copy) so result is pretty accurate. Thank you alot for help!
There was page with tutorial how to do volumetric fog with Z-buffer but unfortunately it’s down and I can’t recreate it.