Magic Leap SDK version:1.18
Unreal Engine version: 5.6.1
ML2 OS version: 1.12.1
Okay, more than a year later, now with the help of almighty Vibe Coding, I have managed to crack segmented dimming on Unreal Engine standalone!!
This finally opens up the Magic Leap 2 to Unreal Engine Development!!
Incredible.
Itβs minor changes in the Unreal Magic Leap plugin and some rendering code in the engine. Also a specific set of config files.
I have included a package here of readme with diff and all modified files + config files.
This is a great joy and now I will continue development on Magic Leap 2 heavily!
Exciting times ahead!
Thank you,
-Brandon
AI CONTEXT:
# Magic Leap 2 Segmented Dimmer Alpha Inversion Fix
**Date:** December 28, 2025
**Engine:** Unreal Engine 5.6
**Platform:** Magic Leap 2
## Problem
The Segmented Dimmer feature was displaying inverted - opaque geometry was pass-through and background was dimmed.
## Root Cause
The AlphaInvert pass was running in `RenderForward()` **before** `AddMobilePostProcessingPasses()`, causing post-processing to overwrite the corrected alpha values.
## Solution
Moved AlphaInvert to the **end** of the mobile post-processing pipeline in `AddMobilePostProcessingPasses()`, matching the desktop rendererβs approach.
-β
## File Structure
```
ML2_SegmentedDimmer_Fix/
βββ Engine/
β βββ Source/
β βββ Runtime/
β βββ Renderer/
β β βββ Private/
β β βββ MobileShadingRenderer.cpp
β β βββ PostProcess/
β β βββ PostProcessing.cpp
β βββ Engine/
β βββ Private/
β βββ SceneTexturesConfig.cpp
βββ Project/
βββ Config/
β βββ DefaultEngine.ini
β βββ Android/
β βββ AndroidEngine.ini
βββ Plugins/
βββ MagicLeapOpenXR/
βββ Source/
βββ MagicLeapOpenXR/
βββ Private/
βββ MagicLeapOpenXR.cpp
```
-β
## Engine Files
### MobileShadingRenderer.cpp
- **Location:** `Engine/Source/Runtime/Renderer/Private/`
- **Change:** Removed early AlphaInvert calls from deferred and forward rendering paths
### PostProcessing.cpp
- **Location:** `Engine/Source/Runtime/Renderer/Private/PostProcess/`
- **Change:** Added AlphaInvert pass to end of `AddMobilePostProcessingPasses()` function
### SceneTexturesConfig.cpp
- **Location:** `Engine/Source/Runtime/Engine/Private/`
- **Change:** Set clear color alpha to 1.0 when `bRequiresAlphaChannel` is true
-β
## Project Files
### DefaultEngine.ini
- **Location:** `Project/Config/`
- **Key Setting:** `xr.OpenXRInvertAlpha=False`
### AndroidEngine.ini
- **Location:** `Project/Config/Android/`
- **Key Settings:**
-
`r.Mobile.PropagateAlpha=1`
-
`r.Mobile.ShadingPath=0`
-
`r.AlphaInvertPass=1`
### MagicLeapOpenXR.cpp
- **Location:** `Project/Plugins/MagicLeapOpenXR/Source/MagicLeapOpenXR/Private/`
- **Change:** Removed programmatic `xr.OpenXRInvertAlpha=true`, only sets `XR_ENVIRONMENT_BLEND_MODE_ALPHA_BLEND`
-β
## Key Changes Summary
### Pipeline Before (Broken)
1. RenderForward/Deferred
2. **AlphaInvert** β Too early!
3. Post-processing (overwrites alpha)
4. OpenXR receives wrong alpha
### Pipeline After (Fixed)
1. RenderForward/Deferred
2. Post-processing
3. **AlphaInvert** β Now at end!
4. OpenXR receives correct alpha
-β
## Configuration Notes
- `XR_EXT_composition_layer_inverted_alpha` is NOT supported by the ML2 runtime
- Alpha inversion must be handled on the renderer side
- `xr.OpenXRInvertAlpha` must be `False` to prevent double inversion
-β
## Installation
1. Copy Engine files to your Unreal Engine source directory
2. Copy Project files to your project directory
3. Rebuild the engine
4. Repackage your project
ML2_SegmentedDimmer_Fix.zip (70.4 KB)