<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <HTML ><HEAD ><TITLE >Depth of Field</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ "><LINK REL="HOME" TITLE="Blender Documentation Volume I - User Guide" HREF="book1.html"><LINK REL="UP" TITLE="Rendering" HREF="c7592.html"><LINK REL="PREVIOUS" TITLE="Motion Blur" HREF="x7845.html"><LINK REL="NEXT" TITLE="Cartoon Edges" HREF="x7989.html"></HEAD ><BODY CLASS="section" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Blender Documentation Volume I - User Guide: Last modified April 29 2004 S68</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="x7845.html" ACCESSKEY="P" ><<< Previous</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Rendering</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="x7989.html" ACCESSKEY="N" >Next >>></A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="rendering_depth_of_field" ></A >Depth of Field</H1 ><P > Depth of Field (DoF) is an interesting effect in real world photography which adds a lot to CG generated images. It is also known as Focal Blur. </P ><P > The phenomenon is linked to the fact that a real world camera can focus on a subject at a given distance, so objects closer to the camera and objects further away will be out of the focal plane, and will therefore be slightly blurred in the resulting photograph. </P ><P > The amount of blurring of the nearest and furthest objects varies a lot with the focal length and aperture size of the lens and, if skilfully used, can give very pleasing effects. </P ><P > Blender's renderer does not provide an automatic mechanism for obtaining DoF, but there are two alternative way to achieve it. One relies solely on Blender's internals, and will be described here. The other requires an external sequence plugin and will be outlined in the Sequence Editor Chapter. </P ><P > The hack to obtain DoF in Blender relies on skilful use of the Motion Blur effect described before, making the Camera move circularly around what would be the aperture of the 'real world camera' lens, constantly pointing at a point where 'perfect' focus is desired. </P ><P > Assume that you have a scene of aligned spheres, as shown on the the left of <A HREF="x7905.html#BSG.REN.F.S68.101" >Figure 24</A >. A standard Blender rendering will result in the image on the right of <A HREF="x7905.html#BSG.REN.F.S68.101" >Figure 24</A >, with all spheres perfectly sharp and in focus. </P ><DIV CLASS="figure" ><A NAME="BSG.REN.F.S68.101" ></A ><DIV CLASS="mediaobject" ><P ><IMG SRC="PartR/rendering/gfx/DoF01.png"></P ></DIV ><P ><B >Figure 24. Depth of Field test scene.</B ></P ></DIV ><P > The first step is to place an Empty (<B CLASS="keycap" >SPACE</B >>>Add>>Empty) where the focus will be. In our case at the center of the middle sphere (<A HREF="x7905.html#BSG.REN.F.S68.102" >Figure 25</A >). </P ><DIV CLASS="figure" ><A NAME="BSG.REN.F.S68.102" ></A ><DIV CLASS="mediaobject" ><P ><IMG SRC="PartR/rendering/gfx/DoF02.png"></P ></DIV ><P ><B >Figure 25. Setting the Focus Empty.</B ></P ></DIV ><P > Then, assuming that your Camera is already placed in the correct position, place the cursor on the Camera (Select the Camera, <B CLASS="keycap" >SHIFT-S</B >>>Curs->Sel) and add a NURBS circle (<B CLASS="keycap" >SPACE</B >>>ADD>>Curve>>NURBS Circle). </P ><P > Out of EditMode (<B CLASS="keycap" >TAB</B >) scale the circle. This is very arbitrary, and you might want to re-scale it later on to achieve better results. Basically, the circle size is linked to the physical aperture size, or diaphragm, of your 'real world camera'. The larger the circle the narrower the region with perfect focus will be, and the more blurred near and far objects will be. The smaller the circle the less evident the DoF blurring will be. </P ><P > Now make the circle track the Empty whith a constraint or the old Tracking as in <A HREF="x7905.html#BSG.REN.F.S68.103" >Figure 26</A >. Since the normal to the plane containing the circle is the local z-axis, you will have to set up tracking correctly so that the local z-axis of the circle points to the Empty and the circle is orthogonal to the line connecting its centre to the Empty. </P ><DIV CLASS="figure" ><A NAME="BSG.REN.F.S68.103" ></A ><DIV CLASS="mediaobject" ><P ><IMG SRC="PartR/rendering/gfx/DoF03.png"></P ></DIV ><P ><B >Figure 26. NURBS circle tracking the focus Empty.</B ></P ></DIV ><P > Select the Camera and then the circle and parent the Camera to the circle (<B CLASS="keycap" >CTRL+P</B >) THe circle will be the Path of the camera so you can either use a normal parent relationship and then set the circle <TT CLASS="literal" >CurvePath</TT > Toggle Button on or use a <TT CLASS="literal" >Follow Path</TT > Parent relationship. </P ><P > With the circle still selected, open an IPO window select the Curve IPO type. The only available IPO is 'Speed'. <B CLASS="keycap" >CTRL+LMB</B > twice at random in the IPO window to add an IPO with two random points. Then set these points numerically by using <B CLASS="keycap" >NKEY</B > to <TT CLASS="literal" >Xmin</TT > and <TT CLASS="literal" >Ymin</TT > to 0, <TT CLASS="literal" >Xmax</TT > and <TT CLASS="literal" >Ymax</TT > to 1. To complete the IPO editing make it cyclic via the <TT CLASS="literal" >Curve>>Extend Mode>>Cyclic</TT > Menu entry. The final result should be as shown in <A HREF="x7905.html#BSG.REN.F.S68.105" >Figure 27</A >. </P ><DIV CLASS="figure" ><A NAME="BSG.REN.F.S68.105" ></A ><DIV CLASS="mediaobject" ><P ><IMG SRC="PartR/rendering/gfx/DoF05.png"></P ></DIV ><P ><B >Figure 27. Speed IPO for the NURBS circle path.</B ></P ></DIV ><P > With these settings we have effectively made the Camera circle around its former position along the NURBS circle path in exactly 1 frame. This makes the Motion Blur option take slightly different views of the scene and create the Focal Blur effect in the end. </P ><P > There is still one more setting to perform. First select the Camera and then the focal Empty, and make the Camera track the Empty the way you prefear. The Camera should now track the Empty, as in <A HREF="x7905.html#BSG.REN.F.S68.106" >Figure 28</A >. </P ><DIV CLASS="figure" ><A NAME="BSG.REN.F.S68.106" ></A ><DIV CLASS="mediaobject" ><P ><IMG SRC="PartR/rendering/gfx/DoF06.png"></P ></DIV ><P ><B >Figure 28. Camera tracking the focal Empty.</B ></P ></DIV ><P > If you press <B CLASS="keycap" >ALT-A</B > now you won't see any movement because the Camera does exactly one full circle path in each frame, so it appears to be still, nevertheless the Motion Blur engine will detect these moves. </P ><P > The last touch is then to go to the rendering buttons window (<B CLASS="keycap" >F10</B >) and select the <TT CLASS="literal" >MBLUR</TT > button. You most probably don't need the <TT CLASS="literal" >OSA</TT > button active, since Motion Blur will implicitly do some antialiasing. It is strongly recommended that you set the Motion Blur factor to 1, since this way you will span the entire frame for blurring, taking the whole circle length. It is also necessary to set the oversamples to the maximum level (16) for best results (<A HREF="x7905.html#BSG.REN.F.S68.107" >Figure 29</A >). </P ><DIV CLASS="figure" ><A NAME="BSG.REN.F.S68.107" ></A ><DIV CLASS="mediaobject" ><P ><IMG SRC="PartR/rendering/gfx/DoF07.png"></P ></DIV ><P ><B >Figure 29. Motion blur settings.</B ></P ></DIV ><P > A rendering (<B CLASS="keycap" >F12</B >) will yield the desired result. This can be much slower than a non-DoF rendering since Blender effectively renders 16 images and then merges them. <A HREF="x7905.html#BSG.REN.F.S68.108" >Figure 30</A > shows the result, to be compared with the one in <A HREF="x7905.html#BSG.REN.F.S68.101" >Figure 24</A >. It must be noted that the circle has been scaled much less to obtain this picture than has been shown in the example screenshots. These latter were made with a large radius (equal to 0.5 Blender units) to demonstrate the technique better. On the other hand, <A HREF="x7905.html#BSG.REN.F.S68.108" >Figure 30</A > has a circle whose radius is 0.06 Blender units. </P ><DIV CLASS="figure" ><A NAME="BSG.REN.F.S68.108" ></A ><DIV CLASS="mediaobject" ><P ><IMG SRC="PartR/rendering/gfx/DoFfinal.png"></P ></DIV ><P ><B >Figure 30. Motion blur final rendering.</B ></P ></DIV ><P > This technique is interesting and with it it's pretty easy to obtain small degrees of Depth of Field. For big Focal Blurs it is limited by the fact that it is not possible to have more than 16 oversamples. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="x7845.html" ACCESSKEY="P" ><<< Previous</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="book1.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="x7989.html" ACCESSKEY="N" >Next >>></A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Motion Blur</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="c7592.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Cartoon Edges</TD ></TR ></TABLE ></DIV ></BODY ></HTML >