Cannot read 'light estimation' values

I’m trying to read light estimation values, but have only manage to read two out of the six values possible. I have made a scripts which should read all six values and display them in a canvas, however this only works for ‘Brightness’ and ‘ColorTemperature’, and the rest has no values in them. The device I’m using is a Iphone 13 pro. Unity version is 2020.3.18 and all package is up to date. I’ve included some images of the setup, since the problem could maybe have something to do with this being wrong. Hope someone can help! :slight_smile:

%%UPDATE%%
I manage to read more values out by using the front facing camera instead which is very confusing to me ?? I am still missing the the most important value for me which is the ‘mainLightColor’. If somebody now how to get this values, please help me.

    using System;
    using UnityEngine;
    using UnityEngine.Rendering;
    using UnityEngine.UI;
    using UnityEngine.XR.ARFoundation;
 
    namespace UnityEngine.XR.ARFoundation.Samples
    {
 
        /// A component that can be used to access the most recently received basic light estimation information
        /// for the physical environment as observed by an AR device.
        [RequireComponent(typeof(Light))]
 
 
        public class LightEstimation : MonoBehaviour
        {
 
            [SerializeField]
            [Tooltip("The ARCameraManager which will produce frame events containing light estimation information.")]
            ARCameraManager m_CameraManager;
            [SerializeField]
            private Text brightnessValue;
            [SerializeField]
            private Text tempValue;
            [SerializeField]
            private Text ColorCorrectionValue;
            [SerializeField]
            private Text mainLightDirectionValue;
            [SerializeField]
            private Text mainLightColorValue;
            [SerializeField]
            private Text mainLightIntensityLumensValue;
            [SerializeField]
            private Text sphericalHarmonicsValue;
 
            /// Get or set the <c>ARCameraManager.
            public ARCameraManager cameraManager
            {
                get { return m_CameraManager; }
                set
                {
                    if (m_CameraManager == value)
                        return;
 
                    if (m_CameraManager != null)
                        m_CameraManager.frameReceived -= FrameChanged;
 
                    m_CameraManager = value;
 
                    if (m_CameraManager != null & enabled)
                        m_CameraManager.frameReceived += FrameChanged;
                }
            }
 
            /// The estimated brightness of the physical environment, if available.
            public float? brightness { get; private set; }
 
            /// The estimated color temperature of the physical environment, if available.
            public float? colorTemperature { get; private set; }
 
 
            /// The estimated color correction value of the physical environment, if available.
            public Color? colorCorrection { get; private set; }
 
            /// The estimated direction of the main light of the physical environment, if available.
            public Vector3? mainLightDirection { get; private set; }
 
            /// The estimated color of the main light of the physical environment, if available.
            public Color? mainLightColor { get; private set; }
 
            /// The estimated intensity in lumens of main light of the physical environment, if available.
            public float? mainLightIntensityLumens { get; private set; }
 
            /// The estimated spherical harmonics coefficients of the physical environment, if available.
            public SphericalHarmonicsL2? sphericalHarmonics { get; private set; }
 
            void Awake()
            {
                ///we fetch directional light reference.
                m_Light = GetComponent<Light>();
 
            }
 
            void OnEnable()
            {
                if (m_CameraManager != null)
                    m_CameraManager.frameReceived += FrameChanged;
 
            }
 
            void OnDisable()
            {
                if (m_CameraManager != null)
                {
                    m_CameraManager.frameReceived -= FrameChanged;
                }
            }
 
 
            void FrameChanged(ARCameraFrameEventArgs args)
            {
                if (args.lightEstimation.averageBrightness.HasValue)
                {
                    brightness = args.lightEstimation.averageBrightness.Value;
                    m_Light.intensity = brightness.Value;
                    brightnessValue.text = "Brightness: " + m_Light.intensity;
 
                }
                else
                {
                    brightness = null;
                    brightnessValue.text = "No value";
                }
 
                if (args.lightEstimation.averageColorTemperature.HasValue)
                {
                    colorTemperature = args.lightEstimation.averageColorTemperature.Value;
                    m_Light.colorTemperature = colorTemperature.Value;
                    tempValue.text = "temp: " + m_Light.colorTemperature;
                }
                else
                {
                    colorTemperature = null;
                    tempValue.text = "No value";
                }
 
                if (args.lightEstimation.colorCorrection.HasValue)
                {
                    colorCorrection = args.lightEstimation.colorCorrection.Value;
                    m_Light.color = colorCorrection.Value;
                    ColorCorrectionValue.text = "correction: " + m_Light.color;
                }
                else
                {
                    colorCorrection = null;
                    ColorCorrectionValue.text = "No value";
                }
 
                if (args.lightEstimation.mainLightDirection.HasValue)
                {
                    mainLightDirection = args.lightEstimation.mainLightDirection;
                    m_Light.transform.rotation = Quaternion.LookRotation(mainLightDirection.Value);
                    mainLightDirectionValue.text = "Direction: " + m_Light.transform.rotation;
 
 
 
                }
                else
                {
                    mainLightDirection = null;
                    mainLightDirectionValue.text = "No value";
                }
 
                if (args.lightEstimation.mainLightColor.HasValue)
                {
                    mainLightColor = args.lightEstimation.mainLightColor;
                    mainLightColorValue.text = "mainLightColor: " + mainLightColor;
                }
                else
                {
                    mainLightColor = null;
                    mainLightColorValue.text = "No value";
                    Console.WriteLine("mainLightColor:  " + args.lightEstimation.mainLightColor);
                }
 
                if (args.lightEstimation.mainLightIntensityLumens.HasValue)
                {
                    mainLightIntensityLumens = args.lightEstimation.mainLightIntensityLumens;
                    m_Light.intensity = args.lightEstimation.averageMainLightBrightness.Value;
                    mainLightIntensityLumensValue.text = "IntensityLumens: " + m_Light.intensity;
                }
                else
                {
                    mainLightIntensityLumens = null;
                    mainLightIntensityLumensValue.text = "No value";
                }
 
 
                if (args.lightEstimation.ambientSphericalHarmonics.HasValue)
                {
                    sphericalHarmonics = args.lightEstimation.ambientSphericalHarmonics;
                    RenderSettings.ambientMode = AmbientMode.Skybox;
                    RenderSettings.ambientProbe = sphericalHarmonics.Value;
                    sphericalHarmonicsValue.text = "Harmonics: " + sphericalHarmonics;
                }
                else
                {
                    sphericalHarmonics = null;
                    sphericalHarmonicsValue.text = "No value";
                }
            }
 
            Light m_Light;
        }

}7615576--946489--Skærmbillede 2021-10-30 kl. 13.36.15.png7615576--946492--Skærmbillede 2021-10-30 kl. 13.34.39.png7615576--946489--Skærmbillede 2021-10-30 kl. 13.36.15.png7615576--946489--Skærmbillede 2021-10-30 kl. 13.36.15.png7615576--946492--Skærmbillede 2021-10-30 kl. 13.34.39.png

If you’re going to post code, please use code-tags otherwise everyone is presented with a wall of plain-text as you can see.

Thanks for the advice @MelvMay , it should be fixed now :slight_smile:

Thanks!

Sorry I can’t actually help you with the content of your post, not my area of expertise unfortunately. Hopefully someone will be along who can help though.

https://docs.unity3d.com/Packages/com.unity.xr.arkit@4.2/manual/index.html#light-estimation

@Fangh Thank you very much… after looking into this I realized that the value I was looking for was already working fine in the project :smile: