Clipping Plane
In order for virtual content to be rendered comfortably, Magic Leap 2 enforces a minimum clipping plane. By default this value is .37 meters or 37 centimeters but can be adjusted by the user inside the device settings (Settings > Display > Advanced > Display Zone) based on their comfort preferences, up to a minimum of 25 centimeters. Applications can choose if they want to use the near clipping plane distance set by the user or if it should remain at the default minimum value. If the Camera's Near Clip Plane value is set to lower than the enforced range it will be reverted to the enforced value.
If you are using OpenXR extensions approved in the OpenXR Specification, these values once at the start of a session. If you go to Settings to change the recommended value, you must quit and relaunch this Unity app to test against the new setting value.
A currently unapproved and experimental OpenXR extension, XR_ML_view_configuration_depth_range_change, reads the device's Display Zone near boundary setting while the app is running.
To learn more about Magic Leap 2's Clipping Plane and Comfort guidelines see the Display Zone and Clipping Plane Documentation.
Configure Clipping Plane Policy
The Near Clip Policy can only be changed inside the editor. By default the enforcement policy is set to Recommended , which means that the Camera's Near Clip Plane will be adjusted based on the user-set value inside the device's settings. However, developers can choose to enforce the maximum clipping plane value. The enforcement policy can be changed inside the Magic Leap Support Feature settings.
- Open the OpenXR Settings (Edit > Project Settings > XR Plugin Management > OpenXR Settings).
- Select the settings (⚙) icon next to the Magic Leap Support listed under the the OpenXR Feature Groups. Select OpenXR and click on Features.
Read Policy at Runtime
Developers are able to query the user's clipping plane setting via the OpenXR Magic Leap Feature nearClipPolicy
. The example script below demonstrates reading the enforcement policy and reading the Camera’s Near Clipping distance.
The Near Clip Enforcement Mode can only be changed inside the editor, before building the application.
using UnityEngine;
using UnityEngine.XR.OpenXR;
using MagicLeap.OpenXR.Features;
public class QueryLocalizationSample : MonoBehaviour
{
private MagicLeapFeature openXrFeature;
private void Start()
{
// The logic for the Enforcement Mode is done in the base MagicLeap OpenXR Feature.
openXrFeature = OpenXRSettings.Instance.GetFeature<MagicLeapFeature>();
Debug.Log($"Enforcement Mode: {openXrFeature.NearClipPolicy}\nClipping plane distance: {Camera.main.nearClipPlane * 100}cm");
}
}