Avatar SDK Unity Cloud plugin  3.0.1
Realistic avatar generation toolset for Unity3D
Scene #04: Parameters Sample

This scene demonstrates API that allows working with computation parameters and flags. These parameters and flags configure which auxiliary features and resources should be generated for the avatar.

The SDK will tell you which resources and parameters are available for your account (this is the full list that you see in the UI). Then before the avatar is generated you can specify which resources you need and which parameters you would like to apply.

Detailed information about parameters can be found in our Web Api Documentation

Accounts with the paid subscription plan will have more resources available and more extended parameters for their avatars.

Currently, the following groups with parameters are available:

  • Haircuts
  • Blendshapes
  • Model Info
  • Avatar Modifications
  • Shape Modifications
  • Additional Textures

Code Usage

ComputationParameters is used to specify required parameters. It is passed to the IAvatarProvider.InitializeAvatarAsync method during avatar initialization.

IEnumerator ConfigureComputationParameters(byte[] photoBytes, PipelineType pipeline)
{
ComputationParameters computationParameters = ComputationParameters.Empty;
computationParameters.modelInfo = new ModelInfoGroup();
computationParameters.modelInfo.age.Value = true;
computationParameters.modelInfo.skinColor.Value = true;
computationParameters.avatarModifications = new AvatarModificationsGroup();
computationParameters.avatarModifications.removeGlasses.Value = true;
computationParameters.avatarModifications.removeSmile.Value = true;
computationParameters.avatarModifications.enhanceLighting.Value = true;
var initializeRequest = avatarProvider.InitializeAvatarAsync(photoBytes, string.Empty, null, pipeline, computationParameters);
yield return initializeRequest;
}

Use IAvatarProvider.GetParametersAsync method to get all available parameters for the given pipelne.

IEnumerator ConfigureComputationParameters(byte[] photoBytes, PipelineType pipeline)
{
var parametersRequest = avatarProvider.GetParametersAsync(ComputationParametersSubset.ALL, pipeline);
yield return parametersRequest;
ComputationParameters availableParameters = parametersRequest.Result;
ComputationParameters specifiedParameters = ComputationParameters.Empty;
specifiedParameters.modelInfo = new ModelInfoGroup();
if (availableParameters.modelInfo.predictHaircut.IsAvailable)
specifiedParameters.modelInfo.predictHaircut.Value = true;
if (availableParameters.modelInfo.hairColor.IsAvailable)
specifiedParameters.modelInfo.hairColor.Value = true;
specifiedParameters.avatarModifications = new AvatarModificationsGroup();
if (availableParameters.avatarModifications.removeGlasses.IsAvailable)
specifiedParameters.avatarModifications.removeGlasses.Value = true;
if (availableParameters.avatarModifications.removeSmile.IsAvailable)
specifiedParameters.avatarModifications.removeSmile.Value = true;
if (availableParameters.avatarModifications.enhanceLighting.IsAvailable)
specifiedParameters.avatarModifications.enhanceLighting.Value = true;
specifiedParameters.blendshapes = availableParameters.blendshapes;
specifiedParameters.haircuts = availableParameters.haircuts;
specifiedParameters.additionalTextures = availableParameters.additionalTextures;
var initializeRequest = avatarProvider.InitializeAvatarAsync(photoBytes, string.Empty, null, pipeline, specifiedParameters);
yield return initializeRequest;
}

Parameters

Haircuts

Unity plugin includes the following sets of artificial haircuts:

  • Base set: 3 male and 3 female haircuts
  • Facegen set: 39 haircuts in total, some of them are unisex
  • Plus set: set of haircuts available for HEAD 2.0 pipeline
  • Generated: haircut generated from the original image (available for HEAD 2.0 pipeline)

It is possible to add custom haircuts to your account. Please contact us at suppo.nosp@m.rt@a.nosp@m.vatar.nosp@m.sdk..nosp@m.com to implement this, we will provide the implementation details on a custom basis. Once the custom haircuts are added, the SDK will return more haircuts in the available haircuts list.

Blendshapes

Avatar SDK supports avatars animation using blendshapes. There are two different blendshapes sets available in the Avatar SDK Unity plugin which should be used depending on your use-case: general animation and lip-sync. E.g. if you want to use lipsync functionality (such as Oculus Lipsync SDK) with your avatar you may want to generate additional visemes blendshapes, but if you don't use lipsync you should tell the SDK to skip these blendshapes to save calculation and download time.

  • legacy_45: Basic set of 45 facial blendshapes.
  • visemes_17: Set of 15 visemes (aa, ch, ee, ih, oh, ou, th, dd, ff, kk, nn, pp, rr, sil, ss) and two additional blendshapes: frown and smile. This set is compatible with Oculus Lipsync that required these 15 visemes. You can find more details here how to use Oculus Lipsync with Avatar SDK: Oculus LipSync Sample
  • mobile_51: Set of 51 facial blendshapes. This set is compatible with Apple ARKit: https://developer.apple.com/documentation/arkit/creating_face-based_ar_experiences (available for HEAD 2.0 pipeline)
  • visemes_15: Set of 14 visemes (PP, FF, TH, DD, kk, CH, SS, nn, RR, aa, E, ih, oh, ou) and one additional blendshape: Laughter. This set is compatible with Oculus Lipsync visemes. You can find more details here on how to use Oculus Lipsync with Avatar SDK: Oculus LipSync Sample

Model Info

This group of flags configures which meta-information should be generated for the avatar.

  • Hair Color: Compute average haircut color from the submitted photo.
  • Skin Color: Compute average skin color from the submitted photo.
  • Gender: Predict a person's gender from the submitted photo (male or female) and confidence.
  • Age: Classify to which age group the person from the photo belongs to. There are two groups: Child and Adult.
  • Facial Landmarks: Compute facial landmarks.
  • Eye Sclera Color: Compute average eye sclera color from the submitted photo.
  • Eye Iris Color: Compute average eye iris color from the submitted photo.
  • Lips Color: Compute average lips color from the submitted photo.
  • Predict Haircut: Predict which haircut matches best to submitted photo. The predicted haircut is chosen from the available haircuts set, not from the selected.
  • Race: Classify to which race the person from the photo belongs to. Possible values are: black, asian and white. The result of prediction is represented as a set of confidence values for possible values.

Colors correspondance:

model_colors.jpg

Parameters availability:

Parameter Name Face pipeline Head 1.2 pipeline Styled Face pipeline Head 2.0 (head/mobile) Head 2.0 (bust/mobile)
Hair Color Plus - Plus Pro Pro
Skin Color Plus Plus Plus Pro Pro
Gender Plus Plus Plus Pro Pro
Age Plus Plus Plus Pro Pro
Facial Landmarks Plus Plus Plus Pro -
Eye Sclera Color Plus Plus Plus Pro Pro
Eye Iris Color Plus Plus Plus Pro Pro
Lips Color Plus Plus Plus - -
Predict Haircut Plus - Plus Pro Pro
Race - Plus - Pro Pro

Avatar Modifications

Group of parameters that allows modifying the avatar:

  • Allow Modify Neck: By default all avatars have the same neck size for all models for easier attaching to the body. If the flag is set to True, the neck will be modified to better match the submitted photo.
  • Curved Bottom: Make the bottom of the Head model slightly curved. Applied only to the Head avatars. See model comparison below.
    curved_bottom.jpg
  • Slightly Cartoonish Texture: Make the model texture looking with a slightly cartoonish effect. Applied only to the Head avatars.
    slightly_cartoonish_head.jpg
  • Parametric eyes texture: Replace eye texture from submitted photo to generated one with sclera and iris colors match the photo version.
    parametric_eyes.png
  • Parametric eyes texture v2: Replace eye texture from submitted photo to generated one with sclera and iris colors match the photo version. add_glare and add_eyelid_shadow flags are ignored when this flag is set to true.
    parametric_eyes_v2.png
  • Add Glare: Add a glare to the eyes on the model texture. Works only when parametric_eyes_texture is set.
    eye_glare.jpg
  • Add Eyelid Shadow: Add an eyelid shadow on the model texture. Works only when parametric_eyes_texture is set.
    eyelid_shadow.jpg
  • Eye Iris Color: Allow to set the iris color. Works only when parametric_eyes_texture is set.
    eye_iris_color.jpg
  • Eye Sclera Color: Allow to set the eye sclera color. Works only when parametric_eyes_texture is set.
    eye_sclera_color.jpg
  • Lips Color: Allow to set the lips color.
    lips_color.png
  • Caricature Amount: Factor to strengthen differences between average model and a particular avatar. Valid values range is [0, +∞). The usable values range is model dependent and usually should be lower than 5.
  • Teeth Color: Recolor teeth directly on a model texture.
    teeth_color.png
  • Hair Color: Recolor generated haircut directly on a haircut texture.
    hair_color.png
  • Texture Size: Size of the resulting model's texture.
  • Generated haircut texture size: Size of generated haircut's texture.
  • Generated haircut faces count: Number of faces in the generated haircut.
    generated_haircut_faces_count.png
  • Remove Smile: Detect smile on input photo and remove it if detected.
    remove_smile.png
  • Remove Glasses: Remove glasses on the submitted photo if detected.
    remove_glasses.png
  • Remove Stubble: Attempt to remove a stubble on the source photo before the actual avatar computation start.
    remove_stubble.jpg
  • Enhance Lighting: Attempt to make lighting more uniform.
    enhance_lighting.png

Parameters availability:

Parameter Name Face pipeline Head 1.2 pipeline Styled Face pipeline Head 2.0 (head/mobile) Head 2.0 (bust/mobile)
Allow Modify Neck Plus - Plus Pro -
Curved Bottom - Plus - - Pro
Slightly Cartoonish Texture - Plus - Pro Pro
Parametric Eyes Texture - Plus Always Set Pro Pro
Parametric Eyes Texture V2 - - - Pro Pro
Add Glare - - Plus Pro Pro
Add Eyelid Shadow - - Plus Pro Pro
Eye Iris Color - - Plus Pro Pro
Eye Sclera Color - - Plus Pro Pro
Lips Color Plus - Plus - -
Caricature Amount Plus - Plus - -
Teeth Color Plus - Plus Pro Pro
Hair Color - - - Pro Pro
Texture Size - - - Pro Pro
Generated haircut texture size - - - Pro Pro
Generated haircut faces count - - - Pro Pro
Remove Smile - Plus - Pro Pro
Remove Glasses - Plus - Pro Pro
Remove Stubble - Plus - Pro Pro
Enhance Lighting - Plus - Pro Pro

Shape Modifications

Group of parameters that allows modifying the avatar geometry:

  • Cartoonish Level v0.3: Level of the cartoon-like stylization. Applied only to the Styled Face pipeline.
  • Cartoonish Level v1.0: Level of the cartoon-like stylization. Applied to the Head 1.2 and Head 2.0 | head/mobile pipelines.
shape_modification_styled_face.jpg
Styled Face, Cartoonish Level v0.3 = 0.75
shape_modification_head_1.2.jpg
Head 1.2, Cartoonish Level v1.0 = 0.75
shape_modification_head_2.0.jpg
Head 2.0 | bust/mobile, Cartoonish Level v1.0 = 0.5

Additional Textures

The list of the additional textures that can be generated along with the default one:

  • slightly_cartoonish_texture: Slightly smoother than regular texture.
    slightly_cartoonish_texture.jpg
  • smooth_eyelashes_texture: Regular texture with smoothen area of eyelashes.
    smooth_eyelashes_texture.jpg
  • lips_mask: Mask of the lips on the regular texture.
    lips_mask.jpg
  • cartoonish_texture: Uniformly colored texture with cartoon-like effect.
    cartoonish_texture.jpg
  • metallic_map: Metallic map
    metallic_map_texture.png
  • roughness_map: Roughness map
    roughness_map_texture.png

Textures availability:

Texture Name Face pipeline Head 1.2 pipeline Styled Face pipeline Head 2.0 (head/mobile) Head 2.0 (bust/mobile)
slightly_cartoonish_texture Plus - Plus - -
smooth_eyelashes_texture Plus - Plus - -
lips_mask Plus Plus Plus Pro Pro
cartoonish_texture - - Plus - -
metallic_map - Plus - - Pro
roughness_map - Plus - - Pro

Implementation

See ParametersSample.cs for implementation details.
See also FAQ and the getting started instructions on the main page: Main Page.
Location: Assets/itseez3d/avatar_sdk/samples_cloud/04_parameters_sample_cloud/scenes/04_parameters_sample_cloud.unity.