# Creating depth of field from Beauty+Depth passes (rendered in another software)

Creating DoF in the compositor is very easy if you have the scene rendered in Blender and the camera depth set right. But what if you rendered a beauty (raw render) and depth pass in another program?

This was rendered in Maya, the white is at the front and the black at the back. There is no "focal distance" value on the Defocus node, so I don't know how to tell it what distance is supposed to be in focus.

I also tried using a regular blur node with "Variable Size" on (Gaussian Type) after putting the depth through a color ramp to remap the values, but this causes areas in focus to have the out-of-focus background blur "bleed" into them:

(The whole worm should be in focus, no blurred edges)

So how should I create depth of field using these two passes alone and no access to the scene itself (since it's in another software)?

• That's an awesome scene. Nov 7 '13 at 6:00

The Defocus node works in conjunction with the settings for the active camera.

You can use this node setup:

You have to check "Use Z-Buffer" so your depth image is used. If you omit the Add node all parts of the image where the depth image is black are sharp independent of your focal settings. I don't know why, maybe that's a bug.

You also have to set the "Distance" to 1.0 with your active camera selected under Properties > Camera Data > Depth of Field.

This is the result:

• Why do you have to set the camera distance to 1.0? Why not 2.0 or 10? Nov 6 '13 at 14:03
• I'm not sure to be honest. But I guess that white in the depth image corresponds to 1.0 and black to 0.0. Nov 6 '13 at 14:44

Well, here is how I'll setup the compositor to do that :

• Defocus node : be sure to check use Z-buffer.
• Set Alpha on the "depth pass image" (the B/W one), with a less than math converter before. This will allow us to override the blurred worm (and other things which are on the same plane) by a focused one. The "Full focused" filed can be controlled by the Less Than value.
• Alpha over : be sure to check Convert Premult.

Note that I only have a 960x540 image to test, so it's a bit pixelated here, but it should work as you expect in full HD. (I hope)

Cheers