Avatar SDK  2.2.1
Realistic avatar generation toolset for Unity3D
Scene #03: Fullbody Sample

The sample shows how to generate full body model with fixed topology and detachable predicted haircut. Predictions may be improved by specifying height, weight and gender of the model.
Please note: the pipeline supports adult bodies only. If you specify parameters as for a child (small height and small weight) then the pipeline will return a body following these parameters, but it will be a body of a small adult, not a child.

The body model can be downloaded from the cloud in the following formats:

  • GLTF (used by default) contains skeleton, body mesh, haircuts meshes and blendshapes. Textures should be downloaded separately.
  • FBX contains skeleton, body mesh, haircuts meshes, blendshapes and textures.
  • PLY contains only body mesh, doesn't support skeleton. Textures and haircuts should be downloaded separately.

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

Sample of usage

CloudAvatarProvider object is utilized to generated and download full body avatar model.
To read the model in GLTF format, use the GLTFAvatarLoader object. This object also is responsible for the configuration of the displayed haircut and for the specifying blendshapes weights.

private IEnumerable InitializeAvatarSdk()
{
if (!AvatarSdkMgr.IsInitialized)
AvatarSdkMgr.Init(sdkType: SdkType.Cloud);
IAvatarProvider avatarProvider = AvatarSdkMgr.GetAvatarProvider();
if (!avatarProvider.IsInitialized)
yield return avatarProvider.InitializeAsync();
}
private IEnumerable GenerateAndDisplayBodyModel(CloudAvatarProvider avatarProvider, byte[] photoBytes)
{
var parametersRequest = avatarProvider.GetParametersAsync(ComputationParametersSubset.ALL, PipelineType.FULLBODY);
yield return parametersRequest;
ComputationParameters parameters = ComputationParameters.Empty;
parameters.blendshapes = parametersRequest.Result.blendshapes;
// Specify the "base\\generated" haircut to be generated
parameters.haircuts.AddValue("base\\generated");
// or uncomment the line below for all available haircuts
//parameters.haircuts = parametersRequest.Result.haircuts;
var initializeRequest = avatarProvider.InitializeAvatarAsync(photoBytes, "name", "description", PipelineType.FULLBODY, parameters);
yield return initializeRequest;
string avatarCode = initializeRequest.Result;
var calculateRequest = avatarProvider.StartAndAwaitAvatarCalculationAsync(avatarCode);
yield return calculateRequest;
var downloadingRequest = avatarProvider.DownloadFullbodyAvatarDataAsync(avatarCode, MeshFormat.GLTF);
yield return downloadingRequest;
// All required data is downloaded. The full body model can be rendered on the scene.
var avatarObject = new GameObject(AVATAR_OBJECT_NAME);
avatarObject.AddComponent<MoveByMouse>();
GLTFAvatarLoader avatarLoader = new GLTFAvatarLoader();
avatarLoader.BodyShader = ShadersUtils.GetHeadShader(false);
yield return avatarLoader.LoadModelOnSceneAsync(currentAvatarCode, avatarObject);
// Show haircut
avatarLoader.ShowHaircut("base\\generated");
}

Parameters

The sample allows to configure various parameters for the avatar.

Haircuts:

  • Base set
  • Plus set
  • Generated haircut

Blendshapes:

  • mobile_51
  • visems_15

Model Info:

  • Hair Color
  • Skin Color
  • Gender
  • Age
  • Facial Landmarks
  • Eye Sclera Color
  • Eye Iris Color
  • Race

Avatar Modifications:

  • Add Glare
  • Add Eyelid Shadow
  • Parametric Eyes
  • Eye Iris Color
  • Eye Sclera Color
  • Hair Color
  • Teeth Color
  • Generated Haircut Face Count
  • Generated Haircut Texture Size
  • Texture Size
  • Remove Smile
  • Remove Glasses
  • Enhance Lighting
  • Gender
  • Height
  • Weight

Gender - guide algorithms what gender generated model should be. The expected value is either male or female. If not specified, gender is autodetected.
Height - guide algorithms what height generated model should approach. The expected value is in meters, greater than zero. This parameter does not take effect without weight specified.
Weight - guide algorithms what weight generated model should approach. The expected value is in kilograms, greater than zero. This parameter does not take effect without height specified.

You can find detailed information about other parameters in our Web Api Documentation or in the Parameters Sample.