Arfoundation-samples: Light estimation not working

Created on 30 Jun 2018  路  2Comments  路  Source: Unity-Technologies/arfoundation-samples

I have enabled light estimation on the AR session but it does not react to the lights. I'm using a Samsung Galaxy S8

good first issue how to

Most helpful comment

This is based on ARKit's UnityARAmbient and works for me:

```c#
using UnityEngine;
using UnityEngine.XR.ARFoundation;

[RequireComponent(typeof(Light))]
public class ARLightAmbient : MonoBehaviour
{
private Light l;

void Start ()
{
    l = GetComponent<Light>();
    ARSubsystemManager.cameraFrameReceived += OnCameraFrameReceived;
}

void OnCameraFrameReceived (ARCameraFrameEventArgs eventArgs)
{
    l.intensity = eventArgs.lightEstimation.averageBrightness.Value;
    l.colorTemperature = eventArgs.lightEstimation.averageColorTemperature.Value;
}

void OnDisable ()
{
    ARSubsystemManager.cameraFrameReceived -= OnCameraFrameReceived;
}

}
```

All 2 comments

The option enables it on the device, but you need to subscribe to the ARSubsystemManager's camerFrame event, which will provide lighting information. ARFoundation does not do anything automatically with this information other than provide it to you.

This is based on ARKit's UnityARAmbient and works for me:

```c#
using UnityEngine;
using UnityEngine.XR.ARFoundation;

[RequireComponent(typeof(Light))]
public class ARLightAmbient : MonoBehaviour
{
private Light l;

void Start ()
{
    l = GetComponent<Light>();
    ARSubsystemManager.cameraFrameReceived += OnCameraFrameReceived;
}

void OnCameraFrameReceived (ARCameraFrameEventArgs eventArgs)
{
    l.intensity = eventArgs.lightEstimation.averageBrightness.Value;
    l.colorTemperature = eventArgs.lightEstimation.averageColorTemperature.Value;
}

void OnDisable ()
{
    ARSubsystemManager.cameraFrameReceived -= OnCameraFrameReceived;
}

}
```

Was this page helpful?
0 / 5 - 0 ratings

Related issues

atom182 picture atom182  路  8Comments

ChakreyaYan picture ChakreyaYan  路  5Comments

guidotalespin picture guidotalespin  路  5Comments

TimmyBest picture TimmyBest  路  6Comments

kennethlng picture kennethlng  路  5Comments