AA for Z Pass?

Compositing with Cycles.
Why is there no AA for the Z pass? Any way i could add it?

Actually you don’t want to AA the depth pass.
Anti-aliasing on the depth pass tends to mess up the blur. Say, you have something in the foreground that would be white (close), against something that would be black (far). If the renderer anti-aliases the edges of the foreground element, the edges of the close object will now have varying degrees of gray in them, which gives conflicting depth information. The DOF blur doesn’t know if the edge of the object is close, or if it is far, or if it is somewhere between, so you get strange edge artefacts with your blur.

For DOF you need a non antialiased Z pass like the render passes did but if you want use the z pass to do something like fog, you will need to use a AA z pass. To do that, it’s really simple: make a new material with the view z depth output of the camera data node into an emission shader and in the render passes panel, make a new layer with this material. It will ouput exactly the same z pass but antialiased. Really usefull.

I am using the Z pass for a FOG, also bilateral blur.
Thanks VincentG :slight_smile:

You can also use the mist passe which is a AA z pass but I don’t like it because you have to set it before rendering and if you change your mind after the render, if you want more or less depth, maybe you will need to recompute the mist pass with other settings. A custom z pass shader contains all informations you will ever need, you just have to use some color corrections nodes to pick what you want.

I found that mist pass before reading your last reply.
And I used it. Works great.
Good thing is, that I don’t have to render a separate render layer with the emission color, so that’s quite faster, even when only using 1 sample for it. Set ithe mist up once, don’t worry about it again :slight_smile:

Is there a tutorial on that? … Yet? … Please? … :yes:

I wrote something similar on my blog to render a position pass (a “z-pass” on the 3 axis) with AA.

You can do exctly what I did and use this node setup instead:

And then, use this shader in a new render layer, it will apply the shader for all objects in this layer.

Ask me if you have any questions.

This is great, thanks, VincentG!