Skip to main content
Version: 20 Mar 2024

Passthrough for Capture and Segmented Dimming

Passthrough is the ability for Unity applications to directly provide the Transparency values associated with material in a Unity scene to the Magic Leap 2. This is the preferred method for ensuring your application looks as-expected in both Mixed Reality capture and through the display with Segmented Dimming.

note

The methods described in this article are specifically relevant to the Magic Leap XR Plugin for Unity, and are not necessarily compatible with the OpenXR plugin. They are also not necessarily compatible with the functionality described in other articles such as Segmented Dimming and Global Dimming.

Setup

Passthrough requires additional configuration in your Unity project. To activate passthrough, include the following snippet of code in any script which is executed in your project:

[DllImport("UnityMagicLeap", CallingConvention = CallingConvention.Cdecl, EntryPoint = "UnityMagicLeap_SegmentedDimmer_KeepAlpha")]
private static extern void SetSegmentedDimmerKeepAlpha(bool status);

void Start(){
SetSegmentedDimmerKeepAlpha(true);
}

For the best experience, we recommend including this in a script which executes as soon as your application launches. There are some considerations which should be made depending on the type of project in which you want to enable passthrough.

New Projects

For brand new projects, there shouldn't be any extra considerations to make aside from ensuring your project executes the code above. If you plan to make use of the Universal Render Pipeline (URP), take a look at the URP Projects section below.

Existing Projects

The passthrough method for capture and dimming is not guaranteed to be compatible with projects that make use of other currently available workflows for supporting opacity in Mixed Reality capture and activation of Segmented Dimming. For more info about Segmented Dimming, see the Segmented Dimming page.

For proper testing and consideration of this method in existing projects which have previously configured Segmented Dimming, remove any extra meshes, scene layers, and the Segmented Dimming URP renderer feature from your project configuration before deciding if this method works for your application.

URP Projects

There are extra considerations that need to be made for projects which make use of the URP. Some post-processing effects such as HDR do not properly preserve material transparency information, and thus are not compatible with the alpha passthrough. Disabling such effects allows passthrough to work as expected even in URP projects. We cannot guarantee that this method will support all functionality possible with the URP.

Non-URP Projects

Projects which do not make use of the URP should support passthrough with no extra effort aside from executing the code snippet above.

Segmented Dimming

Passthrough allows your application to activate the Segmented Dimmer without the need for including additional meshes in your scene or the performance overhead from an extra rendering pass.

To activate or deactivate the dimmer, you can execute the following methods in any script in your project:

// Activates the dimmer
MLSegmentedDimmer.Activate();

// Deactivates the dimmer
MLSegmentedDimmer.Deactivate();

Troubleshooting

Why can’t I see the real world in Mixed Reality captures of my application? You may have some post-processing effect (such as HDR) enabled in your URP Pipeline Asset configuration. Disable any non-essential features to ensure that material Transparency values are not modified before passthrough to your Magic Leap 2 headset.