==============
Depth of Field
==============

When a scene is viewed through a lens, focus is possible at a particular distance. As you move away from this point, objects appear to lose their sharpness. The depth of field is the section of the scene in which geometry is rendered sharply. Outside of the depth of field, objects appear gradually blurrier.

For some scenes, such as landscapes, it is useful to have a very large depth of field. However, in other cases such as portraits, focus on a particular object is necessary and relevant. Depth of field essentially functions as a technique for drawing attention to a specific area of a scene.

HOOPS Visualize Desktop offers the depth of field feature as an option of the ``HPS::WindowKey``. You can also set three parameters: near distance, far distance, and strength. Near and far help determine the area of focus. The near value represents the camera distance in front of which geometry will begin to appear out of focus while the far parameter indicates the camera distance beyond which geometry will appear out of focus. The larger the difference between near and far the greater the depth of field. For a smaller area of focus, decrease the difference between the near and far values. Note that although the range of values for both is from positive to negative infinity, negative values may have little effect since geometry behind the camera is invisible.

Finally, the strength parameter determines the level of contrast between the in-focus and out-of-focus areas of the scene.

.. tabs::

	.. group-tab:: C++
	
		.. literalinclude:: ../../../internals/tests/docs/source/cpp/00700_depth_of_field.cpp
		   :start-after: //! [set_depth_of_field]
		   :end-before: //! [set_depth_of_field]
		   
	.. group-tab:: C#

		.. literalinclude:: ../../../internals/tests/docs/source/cs/00700_depth_of_field.cs
		   :start-after: //! [set_depth_of_field]
		   :end-before: //! [set_depth_of_field]
		   
.. image:: images/depth_of_field.png

*This image shows how depth of field can be used to draw attention to a specific object in a scene.*
