5
$\begingroup$

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?

Beauty Pass

Depth Pass

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:

Remapped depth

Blur Bleed

(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)?

$\endgroup$
1
  • 1
    $\begingroup$ That's an awesome scene. $\endgroup$
    – wchargin
    Nov 7, 2013 at 6:00

2 Answers 2

6
$\begingroup$

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

You can use this node setup:

enter image description here

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:

enter image description here

$\endgroup$
2
  • $\begingroup$ Why do you have to set the camera distance to 1.0? Why not 2.0 or 10? $\endgroup$
    – Greg Zaal
    Nov 6, 2013 at 14:03
  • $\begingroup$ 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. $\endgroup$
    – Maccesch
    Nov 6, 2013 at 14:44
1
$\begingroup$

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.

defocus node setup

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

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .