Material pass and DoF don’t match I’m doing an enormous render for a poster and I have an image with pretty shallow depth of field. I’m trying to make a material pass so I can play with colors when compositing, but I can’t get the DoF of the Materials pass to match the DoF of the main image.

Without the defocus node the blurry section is just black or white dithered pixels. Once I add the defocus node, it just blurs everything, even the sharp areas.

Should I be just doing the depth of field for both the main mage and the material pass in the compositor? Right now I have the DoF of the main image done in the Camera tab.
Pasting the correct answer here for visibility.

All ID passes (materials and object ID) by design are binary (a pixel can only belong to one object): developer.blender.org/T51121  This means you cannot use the ID passes when motionblur, depth of field, or transparency is involved.  In your case, you can use the dofocus node on the material pass to create the DoF as a postprocessing step, which CAN create a blurry mask for you to use.

For defocus to work correctly it needs to access the depth data. So you need to plug the 'Depth' output into the 'Z' input for the defocus node to correctly blur the image.