Description
The FocalDistance
property of the DepthOfField
class specifies the distance from the camera at which the scene is in focus. This value is measured in world units and determines the focal point for the depth of field effect, allowing you to control which parts of the scene appear sharp and which are blurred.
Usage
To use the FocalDistance
property, you can set it to a float
value within the range of 1 to 1000. This range is enforced by the RangeAttribute
, ensuring that the focal distance remains within practical limits for most scenes.
Adjusting the FocalDistance
allows you to simulate different focus effects, such as focusing on objects at varying distances from the camera.
Example
// Example of setting the FocalDistance property
DepthOfField depthOfField = new DepthOfField();
depthOfField.FocalDistance = 50.0f; // Set the focal distance to 50 world units
// This will focus the camera on objects that are 50 units away, blurring objects closer or further away.