Learn how to use Lighting Estimation in your own apps.
This guide is written assuming you have already installed and configured Unity with the ARCore SDK for Unity 1.10.0 or later. If not, see the Unity Quickstart for Android.
Build and run the sample app
Beginning with the ARCore SDK for Unity 1.10, the HelloAR sample for Unity
has Environmental HDR With Reflections mode
EnvironmentalHDRWithReflections) enabled by default.
Create a new project in Unity based on the quickstart.
In Build Settings > Scenes in Build specify the scene from
Make sure your device is connected to your machine and then click Build and Run. Unity builds your project into an Android APK, installs it on the device, and launches it.
Find a location that has varied layers of lighting and shadow in one scene.
Move the device to identify planes planes for placement. As you move your device, the app automatically detects flat surfaces and draws a diamond grid.
Tap the grid to place an Android robot on the surface.
Note the specular highlights, shadows, and ambient light that rendered on the model.
Try adding new Android robots in different parts of the scene. Note how each model conforms to the lighting in a different way.
Configuring Lighting Estimation in your scene
You can configure Unity to select from two Environmental HDR modes or Ambient Intensity mode. After you set a lighting estimation mode, add the Environmental Light prefab to your scene. This prefab will automatically apply ARCore light estimation in your scene.
When the Light Estimation Mode is set to Environmental HDR (with or without reflections), the Environmental Light component will update the rotation and color of the directional light, ambient probe (through
RenderSettings.ambientProbe), and reflection probe (through
When the Light Estimation Mode is set to Ambient Intensity, the Environmental Light component will set the
_GlobalLightEstimationproperty that is used in
ARCore/SpecularWithLightEstimationand other custom shaders to adjust the final color output to match the camera image color.
You can also disable lighting estimation.
To configure Lighting Estimation for new or existing projects:
Open an existing Unity project.
Otherwise, create a new Unity project, then perform one of these steps:
Import the ARCore for Unity SDK: Select Assets > Import Package > Custom Package, then import the
arcore-unity-sdk*.unitypackagewith all options enabled.
Create a new session configuration: Select Assets > Create > Google ARCore > SessionConfig.
If you're working in a new Unity project, configure ARCore prefabs:
From the Project folder, drag the ARCore Device and Environmental Light prefabs into the hierarchy to add them as GameObjects.
The prefabs you just imported already have a camera and directional light. Delete the default camera and the default directional light GameObjects from the root of the same hierarchy.
Your hierarchy should now look something like this:
Choose a Light Estimation mode in the session configuration:
In your project hierarchy, click the ARCore Device GameObject, then double-click the session configuration.
In the session configuration Inspector, click the Light Estimation Mode drop-down, and select the mode you prefer (or disable lighting estimation altogether).
(The default for new projects is Environmental HDR With Reflections.)
Choose the shader that is appropriate to the Lighting Estimation mode:
If you want to use Environmental HDR mode, you can simply use Unity built-in Mobile shaders or Standard Shaders.
If you want to use Ambient Intensity mode, you will need to use a custom shader that apply the
_GlobalLightEstimationterm in the final color output to render your virtual object. See
ARCore/SpecularWithLightEstimationshaders for reference.