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 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.

ppek.SetDepthOfField(true, 5.0f, 5.0f, 30.0f);
myWindowKey.SetPostProcessEffects(ppek);
ppek.SetDepthOfField(true, 5.0f, 5.0f, 30.0f);
myWindowKey.SetPostProcessEffects(ppek);



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