ZBuffer issue with particles rendered in cycles

I’ve whipped up a simple particle test in cycles (based on the blender guru tutorial) and then used the motion vectors and zbuffer to apply motion blur and dof in post. But the resulting dof (from defocus node) looks very very wrong. The middle of the shot doesn’t blur, and nothing i can do changes that. If I do a true 3d dof it looks correct, but the zbuffer seems to delivering incorrect values. Can anyone help?

I’ve included a test scene here. Just bake the particles and render frame 60. The resulting image through the compositor should show pretty extreme DOF except through the middle of the frame. It should also be noted that vector blur is giving spotty results as well, with many particles not blurring at all.


Here is what it should more similar to (this is a 3d dof render)


sparks.zip (1.67 MB)

Hmm, I guess maybe I can ask a broader question concerning this issue. Is blender’s zbuffer producing expected results for everyone? I thought maybe my issue stemmed from the top paticles are rendering against an empty background, but if thats the case, how do I fix it? I added a background to my scene and didnt seem to make a difference, but maybe I doing something else wrong along those lines.

Additionally, I have no idea why the vector blur is producing such poor results. Is that how vector blur normally looks for particles?

This is a very wild guess, but maybe it has something to do with the particles being so small. Iirc, the Defocus doesn’t work too well with large z-buffer differences next to eachother, there’s always some unwanted bleed. You could try this with a cube against a background way in the distance.
Maybe to solve it, create a separate renderlayer with just a screen filling plane at one distance and use the z buffer from that layer to defocus the particles.

I personally never really used vector blur, for similar reasons, doesn’t seem to work too well when there’s a big difference in speed close together. And it doesn’t work on reflections, shadows.

I would also guess that it has to do with particles being very small and you get z-buffer values from ground plane. Added image looks just like it blurs based on groud plane distance. Top part of image contains ground that is far away and thus very blurry. Bottom part is close to camera and also blurry. Dof plane is where the sharp part is and it is the place where ground plane is clipped with dof distance.