# Portrait3D

Both `Portrait3D` and `Portrait2D` inherit from Portrait. As you might expect, one handles 3D portraits, while the other handles 2D portraits.

{% hint style="success" %}
`Portrait3D` should be attached to your 3D Avatar prefab. Check the Portrait Avatar object in the prefabs folder for an example. Learn more about [**creating your own Portrait Avatar**](/magic-pig-games/other/portrait-avatars/setup/create-a-portrait-avatar.md).
{% endhint %}

For this page, we will be looking at the **Portrait Avatar - Demo 3D** object, in the `Portraits/Demo/Prefabs` folder. This is the 3D Avatar used in the demo scene.

{% hint style="info" %}
Note that the **Portrait Avatar - Demo** object has a `DemoAvatarLoader` component on it. In the demo scene, this handles the randomization of the 3D avatar when it is created, using the LoadAvatar() method.

Your custom avatar object will likely have a similar method which handles all the custom logic unique to your project.
{% endhint %}

<figure><img src="/files/48tczTGWvLeKsf1etEQJ" alt=""><figcaption></figcaption></figure>

## Render Texture Width/Height

This will generally be equal values, and 256 is a good starting point. If you find your portraits resolution is low, you can increase this -- 512, 1024, etc. The larger the Render Texture, the more resource intensive your portraits will be. For small portraits on a smaller screen, you may be able to reduce the size.

## Lights

If your 3D Avatar is being lit by lights, add any that you'd like to control the color or intensity of via the [**Portrait Avatars**](/magic-pig-games/other/portrait-avatars/portrait-avatars.md) class to this `array`.

The methods on `PortraitAvatars` include an optional `bool` to only affect the first light in the `array`. Therefor, you may wish to put your main key / front light at the top of the `array`.

## Transition Options

When the `Set()` methods are called, they will default to a transition period, based on the time set here. Call the "Instant" version of the `Set()` methods if you want to skip the transition entirely.

## 3D Plumbing

Add a reference to your [**Avatar Camera**](/magic-pig-games/other/portrait-avatars/avatar-camera.md) class, which should be attached to the camera which is tasked with looking at your 3D Avatar.

## Scripting

The `Portrait3D` class has a number of methods which are most generally called by the [**Portrait Avatars**](/magic-pig-games/other/portrait-avatars/portrait-avatars.md) object. While you can call these directly on the `Portrait3D` object, I suggest you instead choose to use the `PortraitAvatars.instance` to call the versions of the methods there.


---

# 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://infinitypbr.gitbook.io/magic-pig-games/other/portrait-avatars/portrait3d.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.
