CRIWARE Unity Plugin Manual  Last Updated: 2024-07-12
[CriAtom] Custom class that inherits ICriLipsMorph interface

Sample description

Overview

This example demonstrates how to inherit CriWare.ICriLipsMorph to implement a custom morphing class specially made for this application.

Lips Expansion provides the following deformation classes that support the standard functions of the Unity engine.
  • UnityEngine.Animator
  • UnityEngine.SkinnedMeshRenderer
However, in the following situations:
  • the character is controlled by middleware made by another company or an in-house original animation mechanism, etc.
  • you want to combine and morph multiple analysis results from the Lips library
In these situations, the morphing class provided by Lips Expansion may not be sufficient for lip syncing.
In such a case, by inheriting CriWare.ICriLipsMorph ,
you can replace the implementation of the morphing part while maintaining the AtomSource management function of the CriLipsDeformer component.

The following explains how to inherit interfaces and how to handle them.

Please refer to the following page for a detailed explanation of the component itself that registers ICriLipsMorph.


cri4u_samples_criatom_expansion_lipsync_scene06_main.png


Scene information


Middleware ADX LipSync(CRI Lips), CRI ADX (CRI Atom)
Sample Expansion sample
Location /CRIWARE/SDK/unity/samples/UnityProject/Assets/Scenes/criatom/expansion/LipSync
Scene file Scene_06_LipSync_InheritanceICriLipsMorph.unity
ACF file /CRIWARE/SDK/unity/samples/UnityProject/Assets/StreamingAssets/ADXLipSync/ForADXLipSyncSample.acf
ACB file /CRIWARE/SDK/unity/samples/UnityProject/Assets/StreamingAssets/ADXLipSync/ForADXLipSyncSample.acb


Description of the program

Inheriting from ICriLipsMorph

This sample inherits ICriLipsMorph and implements a morphing class that controls the opening/closing ratio of the mouth
using OpenInfo and returns 'extraBlendShapeIndex' depending on the volume value.
public class CustomLipsMorphBlendShapeExtra : ICriLipsMorph {
// Blend shape index that reflects OpenInfo analysis results
public int openIndex;
// Index of blendshape that reacts to the volume value
public int extraBlendShapeIndex;
public void Update(ICriLipsAnalyzeModule analyzeModule) {
analyzeModule.GetOpenInfo(out CriLipsMouth.OpenInfo openInfo);
Target.SetBlendShapeWeight(openIndex, openInfo.openY * 100);
float vol = analyzeModule.GetVolume();
float th = analyzeModule.GetSilenceThreshold();
// By comparing with the noise threshold, the blend shape becomes 0 when Lips is determined to be silent
Target.SetBlendShapeWeight(extraBlendShapeIndex, (vol > th) ? 100 : 0);
}
// (the rest omitted)
}

Inspector settings

Classes that inherit ICriLipsMorph will be automatically provided in the "Morph Target" drop-down menu.
Select 'CustomLipsMorphBlendShapeExtra' and enter the required values.

If you want to extend Editor of your own class, please implement 'CustomPropertyDrawer'.