using System; using UnityEngine.XR.ARSubsystems; namespace UnityEngine.XR.ARFoundation { /// /// Defines types of light estimation. /// [Flags] public enum LightEstimation { /// /// No light estimation. /// None = 0, /// /// An estimate for the average ambient intensity of the environment. /// AmbientIntensity = 1 << 0, /// /// An estimate for the average ambient color of the environment. /// AmbientColor = 1 << 1, /// /// Estimate for the spherical harmonics representing the average ambient lighting of the environment. /// AmbientSphericalHarmonics = 1 << 2, /// /// An estimate for the direction of the main light in the environment. /// MainLightDirection = 1 << 3, /// /// An estimate for the intensity of the main light in the environment. /// MainLightIntensity = 1 << 4, } /// /// Extension methods for the enum. /// public static class LightEstimationExtensions { /// /// Converts a to a Feature. /// /// The being extended. /// A Feature representation of the with the relevant bits enabled. public static Feature ToFeature(this LightEstimation self) { var feature = Feature.None; if ((self & LightEstimation.AmbientIntensity) != LightEstimation.None) feature |= Feature.LightEstimationAmbientIntensity; if ((self & LightEstimation.AmbientColor) != LightEstimation.None) feature |= Feature.LightEstimationAmbientColor; if ((self & LightEstimation.AmbientSphericalHarmonics) != LightEstimation.None) feature |= Feature.LightEstimationAmbientSphericalHarmonics; if ((self & LightEstimation.MainLightDirection) != LightEstimation.None) feature |= Feature.LightEstimationMainLightDirection; if ((self & LightEstimation.MainLightIntensity) != LightEstimation.None) feature |= Feature.LightEstimationMainLightIntensity; return feature; } /// /// Converts a Feature to a enum by extracting the /// relevant light estimation bits from . /// /// The Feature being extended. /// A representation of the relevant Feature bits. public static LightEstimation ToLightEstimation(this Feature self) { var lightEstimation = LightEstimation.None; if ((self & Feature.LightEstimationAmbientIntensity) != Feature.None) lightEstimation |= LightEstimation.AmbientIntensity; if ((self & Feature.LightEstimationAmbientColor) != Feature.None) lightEstimation |= LightEstimation.AmbientColor; if ((self & Feature.LightEstimationAmbientSphericalHarmonics) != Feature.None) lightEstimation |= LightEstimation.AmbientSphericalHarmonics; if ((self & Feature.LightEstimationMainLightDirection) != Feature.None) lightEstimation |= LightEstimation.MainLightDirection; if ((self & Feature.LightEstimationMainLightIntensity) != Feature.None) lightEstimation |= LightEstimation.MainLightIntensity; return lightEstimation; } /// /// Convert the deprecated LightEstimationMode to . /// /// The LightEstimationMode to convert. /// The representation of the LightEstimationMode. [Obsolete("LightEstimationMode is deprecated. (2023-02-22)")] public static LightEstimation ToLightEstimation(this LightEstimationMode mode) { switch (mode) { case LightEstimationMode.AmbientIntensity: return LightEstimation.AmbientIntensity | LightEstimation.AmbientColor; case LightEstimationMode.EnvironmentalHDR: return LightEstimation.AmbientSphericalHarmonics | LightEstimation.MainLightIntensity | LightEstimation.MainLightDirection; default: return LightEstimation.None; } } /// /// Converts a to the deprecated LightEstimationMode. /// /// The being converted. /// A LightEstimationMode representation of the . [Obsolete("LightEstimationMode is deprecated. (2023-02-22)")] public static LightEstimationMode ToLightEstimationMode(this LightEstimation self) { switch (self) { case LightEstimation.AmbientColor: case LightEstimation.AmbientIntensity: return LightEstimationMode.AmbientIntensity; case LightEstimation.AmbientSphericalHarmonics: case LightEstimation.MainLightDirection: case LightEstimation.MainLightIntensity: return LightEstimationMode.EnvironmentalHDR; default: return LightEstimationMode.Disabled; } } } }