Description
The ZNear
property of the CameraComponent
class specifies the near clip plane distance for the camera. This is the closest distance that the camera will be able to render objects. Setting this value too low, particularly below 1, can result in rendering artifacts such as z-fighting. A recommended value for this property is around 5.
Usage
To set the near clip plane distance for a camera in your scene, adjust the ZNear
property of the CameraComponent
instance. Ensure that the value is within the range of 1 to 1000 to avoid rendering issues.
Example
// Create a new CameraComponent
CameraComponent camera = new CameraComponent();
// Set the near clip plane distance
camera.ZNear = 5.0f;
// Ensure the value is within the recommended range
if (camera.ZNear < 1.0f)
{
camera.ZNear = 1.0f; // Set to minimum recommended value
}