您好,我对ARCore材质和前置照明-相机有一些疑问和疑问
当ı从实体画家绘画网格并导出其纹理后,将它们放在统一材质上并分配给网格后,模型很酷,但是当游戏中有灯光时,模型变黑了。纹理没有出现。 如果您有任何建议,我该如何对前置摄像头进行照明处理? 谢谢。
答案 0 :(得分:0)
将摄像机的光照估计应用于场景中的所有光照并使用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}");
}
}
}