The [Lighting Estimation API](https://developers.google.com/ar/develop/unity-arf/lighting-estimation/introduction) provides detailed data that lets you mimic various lighting cues when rendering virtual objects. ARCore supports three light estimation modes:

1. Disabled
2. [Ambient Intensity mode](https://developers.google.com/ar/develop/unity-arf/lighting-estimation/introduction#ambient_intensity_mode)
3. [Environmental HDR mode](https://developers.google.com/ar/develop/unity-arf/lighting-estimation/introduction#environmental_hdr_mode)

## Prerequisites

Make sure that you understand [fundamental AR concepts](https://developers.google.com/ar/develop/fundamentals)
and how to [configure an ARCore session](https://developers.google.com/ar/develop/unity-arf/session-config) before proceeding.

## Enable Lighting Estimation

Follow these steps to enable lighting estimation in your app.

1. Set up an [AR Foundation project](https://developers.google.com/ar/develop/unity-arf/getting-started-ar-foundation) or [ARCore Extensions project](https://developers.google.com/ar/develop/unity-arf/getting-started-extensions).
2. In the **Hierarchy** tab, navigate to **XR Session Origin \> AR Camera**.

![](https://developers.google.com/static/ar/develop/unity-arf/images/lighting-estimation/session-origin-ar-camera.png)

1. Under the **AR Camera Manager** component, select **Light Estimation**.
2. In the **Light Estimation** drop-down menu, select the mode(s) you wish to use.

![](https://developers.google.com/static/ar/develop/unity-arf/images/lighting-estimation/light-estimation-modes.png)

### Enable Environmental HDR mode

[Environmental HDR mode](https://developers.google.com/ar/develop/unity-arf/lighting-estimation/introduction#environmental_hdr_mode) enables the following light estimation settings:

- [Main Light Direction](https://developers.google.com/ar/develop/lighting-estimation#main-directional-light)
- Main Light Intensity
- [Ambient Spherical Harmonics](https://developers.google.com/ar/develop/unity-arf/lighting-estimation/introduction#ambient_spherical_harmonics)

This mode is automatically enabled when the following criteria are met:

- Ambient Spherical Harmonics, Main Light Direction, and/or Main Light Intensity are selected in the Light Estimation mode provided by the [AR Camera manager](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/manual/#ar-camera-manager)
- [Environment probes](https://developers.google.com/ar/develop/unity-arf/lighting-estimation/introduction#environment_probes) are enabled in an [`AREnvironmentProbeManager`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/manual/environment-probe-manager.html)
- A compatible [camera configuration](https://developers.google.com/ar/develop/unity-arf/camera-configs) is selected

### Enable Ambient Intensity mode

Basic light estimation is automatically enabled when [Ambient Intensity mode](https://developers.google.com/ar/develop/unity-arf/lighting-estimation/introduction#ambient_intensity_mode) is selected in the [`ARCameraManager`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/manual/#ar-camera-manager) component.

Ambient Intensity mode enables the following light estimation settings:

- Ambient Color
- Ambient Intensity

## Use lighting information in your scene

Once you have obtained the correct lighting settings, you can light the virtual objects in your scene as if they were a part of the real world.

The [`ARCameraManager`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARCameraManager.html) component can raise a [`frameReceived`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARCameraManager.html#events) event that estimates frames' lighting conditions when lighting estimation is enabled. Information from [`frameReceived`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARCameraManager.html#events) events are stored in [`ARCameraFrameEventArgs`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARCameraFrameEventArgs.html) structs as [`ARLightEstimationData`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARLightEstimationData.html).

Follow these steps to change a light's parameters at runtime.

1. Create or modify the existing Directional Light in your scene.
2. Attach a new script to the Directional Light.

       // Sample Lighting Estimation script

       Light light;
       void Awake ()
       {
           light = GetComponent<Light>();
       }

       void OnEnable()
       {
           if (cameraManager != null)
               cameraManager.frameReceived += FrameChanged;
       }

       void OnDisable()
       {
           if (cameraManager != null)
               cameraManager.frameReceived -= FrameChanged;
       }

       void FrameChanged(ARCameraFrameEventArgs args)
       {
          // Modify `light` parameters using ARCameraFrameEventArgs.
       }

3. Modify this new script to detect changes in lighting. For examples of how to do this, check out Unity's [`BasicLightEstimation.cs`](https://github.com/Unity-Technologies/arfoundation-samples/blob/main/Assets/Scripts/BasicLightEstimation.cs) and [`HDRLightEstimation.cs`](https://github.com/Unity-Technologies/arfoundation-samples/blob/main/Assets/Scripts/HDRLightEstimation.cs) scripts.

### Use environment probes in your scene

Follow these steps to enable [environment probes](https://developers.google.com/ar/develop/unity-arf/lighting-estimation/introduction#environment_probes) in your scene.

1. Enable automatic placement in your scene's [`ARSessionOrigin`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARSessionOrigin.html).
2. Add an [`AREnvironmentProbeManager`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/manual/environment-probe-manager.html) component to the [`ARSessionOrigin`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARSessionOrigin.html).