Avatar SDK Local Compute Unity plugin  3.1.0
Realistic avatar generation toolset for Unity3D
Scene #01: 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 generated in the GLTF format and is shown on the scene at runtime.

Sample of usage

LocalComputeFullbodyAvatarProvider object is utilized to generated 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.LocalCompute);
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;
// FullbodyAvatarLoader is used to display full body avatars on the scene.
FullbodyAvatarLoader avatarLoader = new FullbodyAvatarLoader(fullbodyAvatarProvider);
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 speed up the loading time:

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 the: "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_local_compute/01_fullbody_getting_started_sample_local_compute/scenes/01_fullbody_getting_started_sample_local_compute.unity.