Unreal Engine 5.6 Segmented Dimmer Fix! (Finally!)

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)

1 Like