> For the complete documentation index, see [llms.txt](https://stage-precision.gitbook.io/grid/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stage-precision.gitbook.io/grid/unity-integration/tracking/track-a-camera.md).

# Track a camera

Use SPNet Camera to drive a physical Unity camera with tracking and lens data from Grid Studio.

This example uses Camera ID `1`. Start with the connection described in **Connect Grid Studio and Unity**.

{% content-ref url="/pages/Ja1auhvBW5GmFp7vcqtE" %}
[Connect Grid Studio and Unity](https://stage-precision.gitbook.io/grid/unity-integration/getting-started/connect-grid-studio-and-unity.md)
{% endcontent-ref %}

#### Send camera data from Grid Studio

1. Add or select a **Camera Object** in the **Project Tree**.
2. In **Maps**, add an **SPNet Camera Map Output** and assign your SPNet sender.
3. Set the outgoing camera ID to `1`.

Configure the camera's field of view, aspect ratio, focus distance, aperture and lens settings in Grid Studio. For a live tracking or lens source, connect it to the Camera Object through a Map Input.

The Map Output sends the Camera Object's evaluated tracking and lens data.

<div align="left"><figure><img src="https://1380116828-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fc4nPw8BslCHXa7bL2mf8%2Fuploads%2FgX6ElgqBvW4qm8OnNUrv%2FauHyYF0uUo.gif?alt=media&amp;token=dfaf1575-24eb-4150-a95b-36c34a38f7c3" alt="" width="383"><figcaption></figcaption></figure></div>

#### Create the camera in Unity

1. Choose **GameObject → SPNet → Camera**.
2. Select the new camera in the Hierarchy.
3. In **SPNet Tracked Camera**, set **Camera ID** to `1`.
4. Choose the same aspect ratio in Unity's **Game** view as on the Grid Studio Camera Object.

The Receiver is assigned automatically or created when needed.

If your scene started from the Universal 3D template, disable the original **Main Camera** component when using the newly created SPNet Camera.

To use an existing camera, select it and choose **Add Component → SPNet → SPNet Tracked Camera**.

Adding an SPNet camera also adds **SPNet Camera Lens (URP)** and the **SPNet Lens Renderer Feature** to the camera's active Universal Renderer. New SPNet cameras enable post-processing, **TAA** at **Very High** quality and dithering.

<div align="left"><figure><img src="https://1380116828-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fc4nPw8BslCHXa7bL2mf8%2Fuploads%2F5hOgrxU0tM41OTUxTYaC%2Fimage.png?alt=media&amp;token=25eec619-480a-4556-a111-75581a2cd79c" alt="" width="431"><figcaption></figcaption></figure></div>

#### Camera settings

The following options are enabled by default.

| Setting                  | Effect                                                                               |
| ------------------------ | ------------------------------------------------------------------------------------ |
| **Apply Pose**           | Applies received camera position and rotation in Unity world coordinates.            |
| **Apply Fov**            | Uses the received field of view to update the camera lens.                           |
| **Use Physical Camera**  | Uses Unity's physical camera model, including sensor size and focal length.          |
| **Apply Focus Distance** | Applies the received focus distance in meters.                                       |
| **Apply Aperture**       | Applies the received aperture as an f-number.                                        |
| **Use Depth Of Field**   | Renders depth of field using the camera's focus distance, focal length and aperture. |

Disable an individual **Apply** option to control that property manually in Unity.

With **Preview In Edit Mode** enabled on the Receiver, the camera updates in the Editor. Tracking and lens rendering also run in Play mode.

#### Lens distortion and overscan

**SPNet Camera Lens (URP)** uses the received radial distortion and lens-center settings to render the camera image.

Overscan renders additional image area around the output frame so distortion can sample beyond its original edges.

| Setting               | Default | Effect                                                    |
| --------------------- | ------- | --------------------------------------------------------- |
| **Overscan Override** | On      | Uses the manually configured Overscan Factor.             |
| **Overscan Factor**   | `1.1`   | Sets the amount of overscan when the override is enabled. |

To use the overscan sent by Grid Studio, disable **Overscan Override**. **Overscan Factor** then displays the received value as a read-only field.

SPNet increases the internal render-buffer resolution with overscan, within GPU limits. Larger factors increase rendering cost.
