ZDepth Defocus in Natron

Hello, guys!
I’m experimenting with Natron now and trying to use it for compositing my Blender renders (nothing special really: just merging different render passes and adding some post-effects like vignette, grain, glow, etc.). I’ve managed to make all that stuff in Natron except one particular thing: ZDepth defocus.
Natron doesn’t have (I hope yet) Defocus node (like in Blender), and at first I used just a Blur effect, but then I found a technique called “pixel shift” to simulate defocus. But that’s not the point. And the point is I can’t merge the blurred version of my image with a sharp one using ZDepth (there is ZMask node in Natron) as a mask: Merge node seems just ignores this mask, but adding somewhat glow to the image. And mask works like a charm if I use all the others (regular) mask like Roto, Ramp, Radial or whatever else.
Do I miss something? How to use ZDepth as a mask? I hope there are experienced Natron users among us, who could help me clarify this question.

Here is my node tree from Natron and the results: what I get now (on the left, Natron), and what I’m trying to get (on the right, made in Blender):


Attachments



1 Like

If it were me, I’d take your exr and run it through two shuffles. You’d want your main pass and your zdepth. Then run the main pass into your blur and use the zdepth as a the mask for the blur (may need to run an “A” only merge here to do it). The zdepth might have to be inverted but it should work.

Edit
You can pretty much ignore this. See below

Can you post your EXR and I can take a crack?

Edit
I see what you mean about the glow. I usually use Nuke, but I’ll see if I can figure this out. I tried it with a exr of my own

Here’s what I got and the setup I used. The magic is in the blur node. I do agree though, a proper defocus node would be great!

stc=1stc=1stc=1

Okay, last thing: If you change the blur type to box blur (where mine says “Filter: Guassian”), it might look a little better. I used to cheat DoF in After Effects a few years ago with that. Sorry for the machine gun posting, but people have helped me a lot on here and I love compositing so I wanted to try and help back. I know it’s not pixel shift, but hopefully it helps. I misunderstood and thought that you couldn’t get the overall effect to work.

Last post, I promise! Got it to work
Here’s my merge node. Change the mask layer to one of the RGB layers. It’s the same thing I did with the blur node in my first example. I use RGBA.R as my channel and that allows it to use the mask.
stc=1

Attachments


Wow, El Director, you really showered me with posts :).
I almost gave up to make defocus work properly in Natron (not that I tried much though), but now I’m encouraged to try again, because overall Natron is a great app.
I’ll post the results of my experiments a little later.

So… Here is the result of my experiment.

It’s working. Kind of… You were right, El Director: setting mask to RGBA.R is working, but… There is always but, right? :slight_smile: It seems merging images that way (with ZMask) adds somewhat of glow anyway (in some cases it might be used as artistic effect, I think, almost uncontrollable though). What I found in addition is Gamma option in ZMask node, it works as a “sharpening” factor: the less the Gamma the sharper a transition.

Attachments


I think the glow we’re seeing is just the result of not having a proper lens style defocus node. That said, I think your image looks pretty good. Nice work!

Thank you, El Director. I’ve just finished this loooooong lasting project of mine, and I’ll upload my renders to different galleries soon. Stay tuned!