Composite Node links:
DOF and Motion Blur by cekuhnen https://blenderartists.org/forum/viewtopic.php?t=61399
Simple/quick DOF by purple https://blenderartists.org/forum/viewtopic.php?t=23338&start=1200
A better DOF Technique …
The problem with DOF (depth of field) approximation is that in it’s simplest form the foreground, area of focus and background layers are not separated when performing the blur. This causes the blur to bleed between these layers. However the basic approximation for a sizable focal plane is good enough.
For a more advanced approach you have to …
(1) mask out and blur the foreground
(2) mask out and blur the background
(3) mask out the area of focus
(4) composit these results together so that focal area is over the background and the foreground is over focal area.
I have two examples I have raised the blur quite high so exaggerate the result.
First the basic approximation,
Notice the blur around the mouth and the back of the monkey’s head. This is the bleed I refer to. Try holding your finger a few inches from your eye and focus on something 2 or 3 feet away. You’ll see that there is no distortion of what you are focusing on. Your finger should be out of focus (blurred) with a halo. That’s what we want from the red ball just in front of the monkey.
Second the more advanced approximation (the best result I could get anyway),
The result is deficient in the following ways,
(a) the value mapped Z depth is an approximation. If you look closely at the monkey’s head you notice a jagged line, i.e. a lack of antialiasing. This might be improved by softening the Z depth with a filter before using the colour ramps.
(b) the method of composit (add) dulls the blur overlap - the red glow from foreground over the monkey’s face. This is because I couldn’t use alpha masks in a straight foreword way - I guess you could use color ramps in some way but I couldn’t figure a good method.
Tools I needed that were missing …
(a) an assignAlpha node that took an image and a grayscale image (as the alpha layer to apply). This would make the final composit using overAlpha much more effective than the add I was forced to use.
(b) not really related to the DOF effect but … the group function [ctrl]+[g] is great and everything for organising a hierarchy of nodes but doesn’t present the important parameters for adjustment and I couldn’t figure out if you could descend/transverse/edit a group without ungrouping it. Group function also causes crashes - alot.
See a screen shot of the composit nodes I have used - with brief explanation and spelling mistakes!
Can anyone improve on this? Have I missed something? Is there a different method?
The blend file can be downloaded here. You’ll need a bf build feb 6th or newer. Open it and it and render [f12]. TIP: After the first render if you adjust composit values/assignments you only have to press [f11] to see the result - you do not have to render again.
P.S. When you read monkey please interchange freely with suzzane