void FrameChanged(ARCameraFrameEventArgs args) { if (args.lightEstimation.averageBrightness.HasValue) { brightness = args.lightEstimation.averageBrightness.Value; m_Light.intensity = brightness.Value; } if (args.lightEstimation.averageColorTemperature.HasValue) { colorTemperature = args.lightEstimation.averageColorTemperature.Value; m_Light.colorTemperature = colorTemperature.Value; } if (args.lightEstimation.colorCorrection.HasValue) { colorCorrection = args.lightEstimation.colorCorrection.Value; m_Light.color = colorCorrection.Value; } if (args.lightEstimation.mainLightDirection.HasValue) { mainLightDirection = args.lightEstimation.mainLightDirection; m_Light.transform.rotation = Quaternion.LookRotation(mainLightDirection.Value); } if (args.lightEstimation.mainLightColor.HasValue) { mainLightColor = args.lightEstimation.mainLightColor; #if PLATFORM_ANDROID // ARCore needs to apply energy conservation term (1 / PI) and be placed in gamma m_Light.color = mainLightColor.Value / Mathf.PI; m_Light.color = m_Light.color.gamma; // ARCore returns color in HDR format (can be represented as FP16 and have values above 1.0) var camera = m_CameraManager.GetComponentInParent <Camera>(); if (camera == null || !camera.allowHDR) { Debug.LogWarning($"HDR Rendering is not allowed. Color values returned could be above the maximum representable value."); } #endif } if (args.lightEstimation.mainLightIntensityLumens.HasValue) { mainLightIntensityLumens = args.lightEstimation.mainLightIntensityLumens; m_Light.intensity = args.lightEstimation.averageMainLightBrightness.Value; } if (args.lightEstimation.ambientSphericalHarmonics.HasValue) { sphericalHarmonics = args.lightEstimation.ambientSphericalHarmonics; RenderSettings.ambientMode = AmbientMode.Skybox; RenderSettings.ambientProbe = sphericalHarmonics.Value; } }