Avatar SDK Unity Cloud plugin  3.0.1
Realistic avatar generation toolset for Unity3D
Scene #07: Full Body Getting Started Sample

This sample shows how to generate a naked full body model with the predicted haircut. The full body avatar is downloaded in the GLTF format from the Cloud and is shown on the scene at runtime.

Full body model generation is available on the Pro subscription plan only.

Sample of usage

CloudFullbodyAvatarProvider object is utilized to generated and download full body avatar model.
To read the model in GLTF format and show it on the scene, use the FullbodyAvatarLoader object. This object is also responsible for showing haircuts and outfits.

private IEnumerable InitializeAvatarSdk()
{
if (!AvatarSdkMgr.IsInitialized)
AvatarSdkMgr.Init(sdkType: SdkType.Cloud);
IFullbodyAvatarProvider fullbodyAvatarProvider = AvatarSdkMgr.GetFullbodyAvatarProvider();
if (!fullbodyAvatarProvider.IsInitialized)
yield return fullbodyAvatarProvider.InitializeAsync();
}
private IEnumerator GenerateAndDisplayBodyModel(IFullbodyAvatarProvider fullbodyAvatarProvider, byte[] photoBytes)
{
// Create computation parameters.
FullbodyAvatarComputationParameters computationParameters = new FullbodyAvatarComputationParameters();
// Request "generated" haircut to be computed.
computationParameters.haircuts.names.Add("generated");
// Request "outfit_0" to be computed
computationParameters.outfits.names.Add("outfit_0");
// Generate avatar from the photo and get its code in the Result of request
var initializeRequest = fullbodyAvatarProvider.InitializeFullbodyAvatarAsync(photoBytes, computationParameters, PipelineType.FIT_PERSON);
yield return initializeRequest;
string avatarCode = initializeRequest.Result;
// Wait till avatar is calculated
var calculateRequest = fullbodyAvatarProvider.StartAndAwaitAvatarCalculationAsync(avatarCode);
yield return calculateRequest;
// Download all avatar data from the cloud and store on the local drive
var gettingAvatarModelRequest = fullbodyAvatarProvider.RetrieveAllAvatarDataFromCloudAsync(avatarCode);
yield return gettingAvatarModelRequest;
// FullbodyAvatarLoader is used to display fullbody avatars on the scene.
FullbodyAvatarLoader avatarLoader = new FullbodyAvatarLoader(AvatarSdkMgr.GetFullbodyAvatarProvider());
yield return avatarLoader.LoadAvatarAsync(avatarCode);
// Show "generated" haircut
var showHaircutRequest = avatarLoader.ShowHaircutAsync("generated");
yield return showHaircutRequest;
// Show outfit
var showOutfitRequest = avatarLoader.ShowOutfitAsync("outfit_0");
yield return showOutfitRequest;
}

PBR textures

By default we generate additional (Physically Based Rendering) textures for the body mesh:

  • normal map
  • metallic map
  • roughness map

If you don't need these textures you can disable them to reduce the size of the downloaded data:

computationParameters.additionalTextures.names.Clear();

These textures are applied automatically when the FullbodyAvatarLoader loads the model. You can also turn off them, with the property: UseBodyPBRTextures

The body and outfits meshes are rendered using the Standard shader. The FullbodyMaterialAdjuster is responsible for materials configuration. If you need to use any other specific shader or adjust rendering properties you have to implement corresponding changes in this class or modify templates materials that are located in: "Assets/itseez3d/avatar_sdk/sdk_core/resources/fullbody_materials" project directory.

Implementation

Implementation details of this sample can be found in the FullbodyGettingStartedSample.cs script.

Location: Assets/itseez3d/avatar_sdk/samples_cloud/07_fullbody_getting_strated_sample_cloud/scenes/07_fullbody_getting_started_sample_cloud.unity.