Description
The ZNear
property of the CameraComponent
class specifies the near clipping plane distance for the camera. This is the closest distance at which the camera will render objects. Setting this value too low, particularly below 1, can result in rendering artifacts such as z-fighting. A recommended value is around 5.
Usage
To set the near clipping plane distance for a camera, adjust the ZNear
property. This property is a float
and can be set to any value between 1 and 1000, inclusive. It is important to choose a value that balances rendering performance and visual fidelity, avoiding values that are too low to prevent artifacts.
Example
// Example of setting the ZNear property
CameraComponent camera = new CameraComponent();
camera.ZNear = 5.0f; // Set the near clip plane to 5 units
// Ensure the value is within the recommended range to avoid artifacts
if (camera.ZNear < 1.0f)
{
camera.ZNear = 1.0f; // Adjust to minimum recommended value
}