如何在前置摄像头中调整 ARCore 光估计

How to adjust ARCore light estimation in front camera

你好,我有一些关于 ARCore materials 和前置照明的问题和疑问 - 相机

当我从 substancfe painter 绘制网格并导出其纹理然后将它们统一 material 并且在分配给 mesh.Model 之后很酷但是当光照在 game.Model goes black.Textures 没有出现。 我怎样才能在前置摄像头中进行照明 您能提供什么建议吗? 谢谢。

使用 ARFoundation 为场景中的所有灯光应用来自相机的灯光估计并渲染设置环境光

using UnityEngine;
using System.Collections.Generic;
using UnityEngine.XR.ARFoundation;

public class lightEstimationController: MonoBehaviour
{
    private ARCameraManager arCameraManager;

    private Light[] lights;

    private void Awake() 
    {
        lights = GetComponentsInChildren<Light>();
        arCameraManager = this.GetComponent<ARCameraManager>();
    }

    private void OnEnable() 
    {
        if (arCameraManager)
        arCameraManager.frameReceived += FrameUpdated;
    }

    private void OnDisable() 
    {
        if (arCameraManager)
            arCameraManager.frameReceived -= FrameUpdated;
    }

    private void FrameUpdated(ARCameraFrameEventArgs args)
    {
        if(args.lightEstimation.averageBrightness.HasValue)
        {
            for(int i=0;i< lights.Length; i++)
            {
                lights[i].intensity = args.lightEstimation.averageBrightness.Value;
                
                if (args.lightEstimation.averageColorTemperature.HasValue)
                {
                    lights[i].colorTemperature = args.lightEstimation.averageColorTemperature.Value;
                }

                if (args.lightEstimation.colorCorrection.HasValue)
                {
                    lights[i].color = args.lightEstimation.colorCorrection.Value;
                }
                
            }

            float factor = args.lightEstimation.averageBrightness.Value;
            Color color = new Color(SceneConfig.SceneLightColor.r * factor, SceneConfig.SceneLightColor.g * factor, SceneConfig.SceneLightColor.b * factor);

            RenderSettings.ambientLight = color;

            //   Debug.Log(  $"Color Correction: {args.lightEstimation.colorCorrection.Value}");
            //   Debug.Log($"Color Temperature: {args.lightEstimation.averageColorTemperature.Value}");
            //   Debug.Log ( $"Brightness: {args.lightEstimation.averageBrightness.Value}");
        }



    }
}