Portrait3D
v1.0
Last updated
v1.0
Last updated
Both Portrait3D
and Portrait2D
inherit from Portrait. As you might expect, one handles 3D portraits, while the other handles 2D portraits.
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.
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.
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.
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.
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 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
.
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.
Add a reference to your Avatar Camera class, which should be attached to the camera which is tasked with looking at your 3D Avatar.
The Portrait3D
class has a number of methods which are most generally called by the Portrait Avatars 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.