unreal.MLDeformerMorphModel

class unreal.MLDeformerMorphModel(outer: Object | None = None, name: Name | str = 'None')

Bases: MLDeformerGeomCacheModel

The morph model base class. This is the base class for models that generate and drive morph targets. Use this in combination with UMLDeformerMorphModelInstance or inherited classes.

C++ Source:

  • Plugin: MLDeformerFramework

  • Module: MLDeformerFramework

  • File: MLDeformerMorphModel.h

Editor Properties: (see get_editor_property/set_editor_property)

  • alignment_transform (Transform): [Read-Write] The transform that aligns the Geometry Cache to the SkeletalMesh. This will mostly apply some scale and a rotation, but no translation.

  • anim_sequence (AnimSequence): [Read-Write] The animation sequence to apply to the base mesh. This has to match the animation of the target mesh’s geometry cache. Internally we force the Interpolation property for this motion to be “Step”. deprecated: Use the training input anims instead.

  • clamp_morph_weights (bool): [Read-Write] Should we enable morph target weight clamping? The minimum and maximum values that it will be clamped against will be the min/max morph target weight values that have been seen when running the training dataset through the network. The advantage of clamping is that it can make deformations more stable when we have input poses that have not been seen during training. We basically prevent the weights from ‘exploding’ and getting very large values, which could make the mesh look very bad.

  • delta_cutoff_length (float): [Read-Write] Sometimes there can be some vertices that cause some issues that cause deltas to be very long. We can ignore these deltas by setting a cutoff value. Deltas that are longer than the cutoff value (in units), will be ignored and set to zero length.

  • geometry_cache (GeometryCache): [Read-Write] The geometry cache that represents the target deformations. deprecated: Use the training input anims instead.

  • include_normals (bool): [Read-Write] Include vertex normals in the morph targets? The advantage of this can be that it is higher performance than recomputing the normals. The disadvantage is it can result in lower quality and uses more memory for the stored morph targets.

  • invert_mask_channel (bool): [Read-Write] Enable this if you want to invert the mask channel values. For example if you painted the neck seam vertices in red, and you wish the vertices that got painted to NOT move, you have to invert the mask. On default you paint areas where the deformer should be active. If you enable the invert option, you paint areas where the deformer will not be active.

  • mask_channel (MLDeformerMaskChannel): [Read-Write] The channel data that represents the delta mask multipliers. You can use this feather out influence of the ML Deformer in specific areas, such as neck line seams, where the head mesh connects with the body. The painted vertex color values will be like a weight multiplier on the ML deformer deltas applied to that vertex. You can invert the mask as well.

  • max_num_lo_ds (int32): [Read-Write] How many Skeletal Mesh LOD levels should we generate MLD lods for at most? Some examples: A value of 1 means we only store one LOD, which means LOD0. A value of 2 means we support this ML Deformer on LOD0 and LOD1. A value of 3 means we support this ML Deformer on LOD0 and LOD1 and LOD2. We never generate more LOD levels for the ML Deformer than number of LOD levels in the Skeletal Mesh, so if this value is set to 100, while the Skeletal Mesh has only 4 LOD levels, we will only generate and store 4 ML Deformer LODs. The default value of 1 means we do not support this ML Deformer at LOD levels other than LOD0. When cooking, the console variable “sg.MLDeformer.MaxLODLevelsOnCook” can be used to set the maximum value per device or platform.

  • max_training_frames (int32): [Read-Write] The maximum numer of training frames (samples) to train on. Use this to train on a sub-section of your full training data.

  • morph_compression_level (float): [Read-Write] The morph target compression level. Higher values result in larger compression, but could result in visual artifacts. Most of the times this is a value between 20 and 200.

  • morph_delta_zero_threshold (float): [Read-Write] Morph target delta values that are smaller than or equal to this threshold will be zeroed out. This essentially removes small deltas from morph targets, which will lower the memory usage at runtime, however when set too high it can also introduce visual artifacts. A value of 0 will result in the highest quality morph targets, at the cost of higher runtime memory usage.

  • skeletal_mesh (SkeletalMesh): [Read-Write] The skeletal mesh that represents the linear skinned mesh.

  • training_input_anims (Array[MLDeformerGeomCacheTrainingInputAnim]): [Read-Write]

can_dynamically_update_morph_targets() bool

Can Dynamically Update Morph Targets

Return type:

bool

set_morph_target_delta_floats(deltas) None

Set the per vertex deltas, as a set of floats. Each vertex delta must have 3 floats. These deltas are used to generate compressed morph targets internally. You typically call this method from inside the python training script once your morph target deltas have been generated there. Concatenate all deltas into one buffer, so like this [morphdeltas_target0, morphdeltas_target1, …, morphdeltas_targetN]. The vertex ordering should be: [(x, y, z), (x, y, z), (x, y, z)]. This is the same as SetMorphTargetDeltas, except that this takes an array of floats instead of vectors.

Parameters:

deltas (Array[float]) – The array of floats that contains the deltas. The number of items in the array must be equal to (NumMorphs * NumBaseMeshVerts * 3).

set_morph_target_deltas(deltas) None

Set the morph target model deltas as an array of 3D vectors. These deltas are used to generate compressed morph targets internally. You typically call this method from inside the python training script once your morph target deltas have been generated there. Concatenate all deltas into one buffer, so like this [morphdeltas_target0, morphdeltas_target1, …, morphdeltas_targetN]. This is the same as SetMorphTargetDeltaFloats, except that it takes vectors instead of floats.

Parameters:

deltas (Array[Vector3f]) – The array of 3D vectors that contains the vertex deltas. The number of items in the array must be equal to (NumMorphs * NumBaseMeshVerts).

set_morph_targets_error_order(morph_target_order, error_values) None

Set the order of importance during LOD, for the morph targets. Basically this specifies the sorted order of the morph targets, based on the error they introduce when disabling them.

Parameters:
  • morph_target_order (Array[int32]) – The array of morph target indices, starting with the most important morph target, and ending with the least important morph target’s index.

  • error_values (Array[float]) – The error value for each morph target (not sorted), so index 0 contains the error value of the first morph target, which isn’t necesarrily the one with highest error.

set_morph_targets_max_weights(max_weights) None

Set Morph Targets Max Weights

Parameters:

max_weights (Array[float]) –

set_morph_targets_min_max_weights(min_values, max_values) None

Set the minimum and maximum values that the morph targets weights have seen during training. We can clamp the network output weights within these ranges to try to make sure that the output doesn’t go wild when we give inputs that are far outside of the range we have seen during training. The size of the array must equal the number of morph targets, or empty. In case it is empty, clamping will be ignored, even when enabled.

Parameters:
  • min_values (Array[float]) – The minimum weigth values, one for each morph target.

  • max_values (Array[float]) – The maximum weight values, one for each morph target.