# CG Focus Controller

## Controller Description

The CG Focus Controller is a controller that adjusts the desired focus distance of the smartphone's camera according to the distance between the Virtual Camera Actor and the Virtual Object of focus.

### Use Case

The CG Focus Controller was developed to tackle the problem of setting the camera focus distance to match the distance of CG/virtual objects. Since with the CameraTwin application the smartphone's camera parameters are matched with the Virtual CineCamera Actor, that means that the focus distance of both is set based on the focus settings of the smartphone.\
In the case of automatic focus the smartphone is estimating the actual distance of the objects in view and it adjusts the lenses to focus on that distance. In the case of manual focus the phone is focusing on that specific distance. In both cases the Virtual objects, like an AR character, are not perfectly in focus throughout the shoot as the camera is moving. For that reason the CG Focus controller was developed in order to automatically calculate the distance between the Virtual Camera Actor and the Virtual Character or Actor that needs to be in focus. This distance is then set as the desired focus distance to the phone and it dynamically changes on every frame.

## Setup and Usage

### Create the Controller

To create the CG Focus Controller you can either go to the Camera Parameters Manager of your desired Camera Actor

<figure><img src="/files/rCr4PiFP8GC42z9JHP98" alt="" width="501"><figcaption></figcaption></figure>

Add a new Controller in the list of the Camera Controllers

<figure><img src="/files/3uRQYMYRWCYBlxsnNzHp" alt="" width="498"><figcaption></figcaption></figure>

Create a new CG Focus Controller Asset from the dropdown

<figure><img src="/files/A3p2nFNhuswikrTfVkcD" alt="" width="498"><figcaption></figcaption></figure>

Or alternatively right click in content browser and start typing "CG Focus Camera Parameters Controller"

### Set the Actor of Focus

Open the CG Focus Controller Asset and set the "Actor to Focus" field with the Actor you desire to focus on

<figure><img src="/files/knOUmZg0m4uMY1R8Lpto" alt="" width="563"><figcaption></figcaption></figure>

### Usage

Make sure that the phone is set to "Remote" Mode for the Focus-Zoom pair, you can find more information about that [here](/cameratwin/documentation/mobile-applications/advanced-camera-controls.md#camera-control-modes).

After that you are ready to shoot your AR shot with your CG character in focus!

## Controller of:

{% content-ref url="/pages/eFaengqiCk5bdtHgTdDO" %}
[Camera Parameters Manager](/cameratwin/documentation/unreal-engine-plugin/camera-parameters-manager.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.realtwin.org/cameratwin/documentation/unreal-engine-plugin/camera-parameters-manager/cg-focus-controller.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
