# Global Dimming doesn't work

**URL:** <https://forum.magicleap.cloud/t/global-dimming-doesnt-work/3258>\
**Category:** Unity Development\
**Tags:** global-dimmer, display-modes\
**Created:** [March 8, 2024, 10:30am UTC](https://forum.magicleap.cloud/t/global-dimming-doesnt-work/3258 "2024-03-08T10:30:44Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![yanghouze](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/yanghouze/32/1470_2.png) [@yanghouze](https://forum.magicleap.cloud/u/yanghouze)\
**Post date:** [March 8, 2024, 10:30am UTC](https://forum.magicleap.cloud/t/global-dimming-doesnt-work/3258/1 "2024-03-08T10:30:45Z")

</div>

Hi, I am testing the global dimming of magic leap 2 with this code:

```auto
using UnityEngine;
using TMPro; 
using UnityEngine.XR.MagicLeap; 

public class DimmerTest : MonoBehaviour
{
    public float period = 2.0f;
    [SerializeField, Tooltip("Debug bar")]
    private TextMeshProUGUI DebugText;

    void Update()
    { 
        float t = (Time.timeSinceLevelLoad % period) / period;
        float dimmer = -0.5f * Mathf.Cos(2.0f * Mathf.PI * t) + 0.5f;

        try
        {
            MLGlobalDimmer.SetValue(dimmer);
            Debug.Log("Set dimmer to " + dimmer);
            DebugText.text = $"Dimmer level: {dimmer:0.00}";
        }
        catch (System.Exception e)
        {
            Debug.Log(e.Message);
            DebugText.text = $"Error setting dimmer: {e.Message}";
        }
    }
}

```

When I test this code with both App simulation/real device, it successfully printed out the Dimmer level with no error output. Also, the code are all complied correctly. However, in my view of glasses, the background didn't changed at all while it should be frequently changed from black to light as the doc below shows.

> **[Global/Segmented Dimmer | MagicLeap Developer Documentation](https://developer-docs.magicleap.cloud/docs/guides/features/dimmer-feature/#what-is-global-dimming)**
>
> Magic Leap devices have additive displays, which take the light within a user’s environment and add photons to the display, making it possible to render content. The Magic Leap 2 introduces a new low resolution panel which selectively subtracts...

For information of my system, I am on WIndows 10, using unity 2022.2.0.f1, MLC SDK is 1.5.0 and Magic Leap Application Simulator (ZI) Runtime version is 3.8.0.20231028, and the ML2 OS version is 1.4.1.

Any hints will be appreciate.

---

<div class="post-metadata">

**Author:** ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)\
**Post date:** [March 8, 2024, 3:10pm UTC](https://forum.magicleap.cloud/t/global-dimming-doesnt-work/3258/2 "2024-03-08T15:10:35Z")

</div>

The global dimmer will not work in app simulator. Are you using the OpenXR Workflow or the standard XR Workflow?

---

<div class="post-metadata">

**Author:** ![yanghouze](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/yanghouze/32/1470_2.png) [@yanghouze](https://forum.magicleap.cloud/u/yanghouze)\
**Post date:** [March 8, 2024, 5:24pm UTC](https://forum.magicleap.cloud/t/global-dimming-doesnt-work/3258/3 "2024-03-08T17:24:44Z")

</div>

I am using the standard XR workflow with Unity MLSDK.  
I referred the page here:

> **[Global Dimming | MagicLeap Developer Documentation](https://developer-docs.magicleap.cloud/docs/guides/unity/display/unity-global-dimming/)**
>
> Learn how to use the Magic Leap 2's unique global dimming technology.

---

<div class="post-metadata">

**Author:** ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)\
**Post date:** [March 8, 2024, 5:46pm UTC](https://forum.magicleap.cloud/t/global-dimming-doesnt-work/3258/4 "2024-03-08T17:46:29Z")

</div>

If you are using the XR Workflow, do you mind using the 1.12.0 Unity SDK in your project if you are not already doing so?

---

<div class="post-metadata">

**Author:** ![yanghouze](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/yanghouze/32/1470_2.png) [@yanghouze](https://forum.magicleap.cloud/u/yanghouze)\
**Post date:** [March 8, 2024, 5:48pm UTC](https://forum.magicleap.cloud/t/global-dimming-doesnt-work/3258/5 "2024-03-08T17:48:02Z")

</div>

Thank you, I will try that but not sure if there will be some conflict if I downgrade to 1.12.0. Is XR Workflow no more support global dimming/have some potential problems with SDK version higher than 1.12.0? Will that be fixed in the future as we also want to add pupil size detection if it is supported in the future version.

---

<div class="post-metadata">

**Author:** ![yanghouze](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/yanghouze/32/1470_2.png) [@yanghouze](https://forum.magicleap.cloud/u/yanghouze)\
**Post date:** [March 8, 2024, 5:54pm UTC](https://forum.magicleap.cloud/t/global-dimming-doesnt-work/3258/6 "2024-03-08T17:54:54Z")

</div>

Also, I don't think there are MLSDK package with version 1.12.0 on Magic leap hub. If you mean the Unity package, I am currently using 2.0 and can downgrade to 1.12.0

---

<div class="post-metadata">

**Author:** ![yanghouze](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/yanghouze/32/1470_2.png) [@yanghouze](https://forum.magicleap.cloud/u/yanghouze)\
**Post date:** [March 8, 2024, 6:11pm UTC](https://forum.magicleap.cloud/t/global-dimming-doesnt-work/3258/7 "2024-03-08T18:11:18Z")

</div>

Hi, I have tried with the Unity package 1.12.0 and it still doesn't work. The performance was same as I described above.

---

<div class="post-metadata">

**Author:** ![yanghouze](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/yanghouze/32/1470_2.png) [@yanghouze](https://forum.magicleap.cloud/u/yanghouze)\
**Post date:** [March 11, 2024, 8:41pm UTC](https://forum.magicleap.cloud/t/global-dimming-doesnt-work/3258/8 "2024-03-11T20:41:24Z")

</div>

Hi, this solution doesn't work, are there any other possible ways to fix it?

---

<div class="post-metadata">

**Author:** ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)\
**Post date:** [March 12, 2024, 4:00pm UTC](https://forum.magicleap.cloud/t/global-dimming-doesnt-work/3258/9 "2024-03-12T16:00:30Z")

</div>

Can you verify that the dimmer works properly in the 1.12.0 Magic Leap Unity Examples?

Note, this is the script that is used in the example project:

```csharp
    public class GlobalDimmerExample : MonoBehaviour
    {
        [SerializeField, Range(0f, 1f)]
        private float startingValue = 0.2f;

        [SerializeField]
        private UnityEngine.UI.Slider slider;

        private void Start()
        {
            slider.value = startingValue;
        }

        public void SetDimmerValue(float value)
        {
            MLGlobalDimmer.SetValue(value);
        }
    }

```

You may want to check your device's display settings and make sure that the Max Dimming value was not disabled.

---

<div class="post-metadata">

**Author:** ![yanghouze](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/yanghouze/32/1470_2.png) [@yanghouze](https://forum.magicleap.cloud/u/yanghouze)\
**Post date:** [March 12, 2024, 10:46pm UTC](https://forum.magicleap.cloud/t/global-dimming-doesnt-work/3258/10 "2024-03-12T22:46:04Z")

</div>

Hi, you are correct. In the setting part, the Global dimming is disabled with notification: disabled due to display preset  
However, I didn't found any options in display setting page to enable it. May I have some hints about how to enable it?  
 ![Capture](https://us1.discourse-cdn.com/flex019/uploads/magicleap1/original/2X/b/bdb057e5f39b5658f5788938aca904b77b648caa.png)

---

<div class="post-metadata">

**Author:** ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)\
**Post date:** [March 13, 2024, 6:14pm UTC](https://forum.magicleap.cloud/t/global-dimming-doesnt-work/3258/11 "2024-03-13T18:14:11Z")

</div>

The Display Modes option under Display Override can be adjusted.

---

<div class="post-metadata">

**Author:** ![yanghouze](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/yanghouze/32/1470_2.png) [@yanghouze](https://forum.magicleap.cloud/u/yanghouze)\
**Post date:** [March 13, 2024, 9:08pm UTC](https://forum.magicleap.cloud/t/global-dimming-doesnt-work/3258/12 "2024-03-13T21:08:45Z")

</div>

Thank you, it works.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/magicleap1/original/1X/bd9b737a4d45ea243aa7eb177d60a773b806899a.svg) [@system](https://forum.magicleap.cloud/u/system)\
**Post date:** [March 28, 2024, 9:08pm UTC](https://forum.magicleap.cloud/t/global-dimming-doesnt-work/3258/13 "2024-03-28T21:08:58Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
