> [!NOTE]
> **Note:** This API does not require ARCore Extensions for AR Foundation.

Learn how to use [Augmented Faces](https://developers.google.com/ar/develop/unity-arf/augmented-faces/introduction) to render assets on top of human faces in your own app.

## 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.

## Detect faces

Faces are represented by [`ARFace`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARFace.html) objects that are created, updated, and removed by the [`ARFaceManager`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARFaceManager.html). Once per frame, the [`ARFaceManager`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARFaceManager.html) invokes a [`facesChanged`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARFaceManager.html#UnityEngine_XR_ARFoundation_ARFaceManager_facesChanged) event that contains [three lists](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARFacesChangedEventArgs.html#properties): faces that have been added, faces that have been updated, and faces that have been removed since the last frame. When the [`ARFaceManager`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARFaceManager.html) detects a face in the scene, it will instantiate a Prefab with an [`ARFace`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARFace.html) component attached to track the face. The Prefab can be left `null`.

To set up the [`ARFaceManager`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARFaceManager.html), create a new game object and add the [`ARFaceManager`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARFaceManager.html) to it.

![](https://developers.google.com/static/ar/develop/unity-arf/images/augmented-faces/ar-face-manager.png)

**Face Prefab** is the Prefab instantiated at the face's center pose. **Maximum Face Count** represents the maximum amount of faces that can be tracked.

> [!NOTE]
> **Note:** Currently, AR Foundation targeting Android devices can only track a single face at a time.

## Access detected faces

Access detected faces through the [`ARFace`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARFace.html) component, which is attached to the Face Prefab. [`ARFace`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARFace.html) provides vertices, indices, vertex normals, and texture coordinates.

## Parts of a detected face

The Augmented Faces API provides a center pose, three region poses, and a 3D face mesh.

### Center pose

The center pose, which marks the center of a user's head, is the origin point of the Prefab instantiated by the [`ARFaceManager`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARFaceManager.html). It is located inside the skull, behind the nose.

![](https://developers.google.com/static/ar/develop/unity-arf/images/augmented-faces/unity-arf-center-point.jpg)

The axes of the center pose are as follows:

- The positive X-axis (X+) points toward the left ear
- The positive Y-axis (Y+) points upwards out of the face
- The positive Z-axis (Z+) points into the center of the head

### Region poses

Located on the left forehead, right forehead, and tip of the nose, region poses mark important parts of a user's face. The region poses follow the same axis orientation as the center pose.

To use the region poses, downcast the [`ARFaceManager`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARFaceManager.html)'s subsystem to [`ARCoreFaceSubsystem`](https://docs.unity3d.com/Packages/com.unity.xr.arcore@4.2/api/UnityEngine.XR.ARCore.ARCoreFaceSubsystem.html) and use [`subsystem.GetRegionPoses()`](https://docs.unity3d.com/Packages/com.unity.xr.arcore@4.2/api/UnityEngine.XR.ARCore.ARCoreFaceSubsystem.html#UnityEngine_XR_ARCore_ARCoreFaceSubsystem_GetRegionPoses_TrackableId_Allocator_NativeArray_UnityEngine_XR_ARCore_ARCoreFaceRegionData___) to obtain pose information for each region. For an example of how to do this, see Unity's [usage sample](https://github.com/Unity-Technologies/arfoundation-samples/blob/main/Assets/Scripts/ARCoreFaceRegionManager.cs#:%7E:text=subsystem.GetRegionPoses) on GitHub.

## 3D face mesh

The face mesh consists of 468 points that make up a human face. It is also defined relative to the center pose.

![](https://developers.google.com/static/ar/images/augmented-faces/augmented-faces-468-point-face-mesh.png)

To visualize the face mesh, attach an [`ARFaceMeshVisualizer`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARFaceMeshVisualizer.html) to the **Face Prefab** . The [`ARFaceMeshVisualizer`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARFaceMeshVisualizer.html) will generate a [`Mesh`](https://docs.unity3d.com/ScriptReference/Mesh.html) that corresponds to the detected face, setting it as the mesh in the attached [`MeshFilter`](https://docs.unity3d.com/ScriptReference/MeshFilter.html)s and [`MeshCollider`](https://docs.unity3d.com/ScriptReference/MeshCollider.html)s. Use a [`MeshRenderer`](https://docs.unity3d.com/ScriptReference/MeshRenderer.html) to set the [`Material`](https://docs.unity3d.com/Manual/Materials.html) used to render the face.

The **AR Default Face Prefab** renders a default material on detected face meshes.

![](https://developers.google.com/static/ar/develop/unity-arf/images/augmented-faces/visualized-face-mesh.png)

Follow these steps to start using the AR Default Face:

1. Set up an [`ARFaceManager`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARFaceManager.html).
2. In the **Hierarchy** tab, use **+** \> **XR** \> **AR Default Face** to create a new face object. This object is temporary and can be deleted once you create the Face Prefab.

   ![](https://developers.google.com/static/ar/develop/unity-arf/images/augmented-faces/new-face-object.png)
3. Access the **AR Default Face** in the Inspector.

   ![](https://developers.google.com/static/ar/develop/unity-arf/images/augmented-faces/ar-default-face.png)
4. Drag the newly created AR Default Face from the **Hierarchy** tab into the **Project Assets** window to [create a Prefab](https://docs.unity3d.com/Manual/CreatingPrefabs.html).

5. Set the newly created Prefab as the Face Prefab in the [`ARFaceManager`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARFaceManager.html)'s **Face Prefab** field.

6. In the **Hierarchy** tab, delete the face object, as it's no longer needed.

### Access individual vertices of the face mesh

Use [`face.vertices`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARFace.html#UnityEngine_XR_ARFoundation_ARFace_vertices) to access the positions of the face mesh's vertices. Use [`face.normals`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARFace.html#UnityEngine_XR_ARFoundation_ARFace_normals) to access the corresponding vertex normals.

### Visualize individual vertices of the face mesh

You can use [Blender](https://www.blender.org/download/) to easily view the index numbers that correspond to a face mesh's vertices:

1. Open Blender and import [`canonical_face_mesh.fbx`](https://github.com/google-ar/arcore-android-sdk/blob/master/assets/canonical_face_mesh.fbx) from GitHub.
2. Navigate to **Edit \> Preferences \> Interface**.
3. Under the **Display** menu, select **Developer Extras**.

   ![](https://developers.google.com/static/ar/develop/unity-arf/images/augmented-faces/blender-developer-extras.png)
4. Select the face by clicking it in the 3D viewport, and press Tab to enter Edit Mode.

5. Open the drop-down menu next to the **Overlays** viewport and select **Indices**.

   ![Blender face mesh indices](https://developers.google.com/static/ar/develop/unity-arf/images/augmented-faces/blender-face-mesh-indices.png)

   ![](https://developers.google.com/static/ar/develop/unity-arf/images/augmented-faces/blender-face-mesh-indices.png)
6. Highlight the vertex whose index number you would like to determine. To highlight all vertices, use **Select \> All**.