Tutorial: Chaos Flesh Muscle Simulation Tutorial (5.6)

Physics Engineer Yushan Han goes over the process of setting up a Chaos Flesh simulation, using a provided Emil muscle asset and detailing the new 5.6 features.

https://dev.epicgames.com/community/learning/tutorials/RZwB/unreal-engine-chaos-flesh-muscle-simulation-tutorial-5-6

In 5.6 chaos flesh, can we mirror the paint weights of insertion and origins??

Hi, this is doable through applying a custom transform (TransformCollectionAttribute) and appending the transformed collection to the original one (AppendTetrahedralCollection).

1 Like

Hi, I have run into the issue of the elbow clipping through the fat layer in the fat simulation process. I initally followed all of the given parameters and went over it multiple times to ensure it was correct. First I had both a clipping of the muscle and the elbow problem. The former I could fix by increasing the Position Target Stiffness to 30.0. But the elbow problem remains. I have tried increasing the search radius and the substeps and iterations to 10 and 40 respectively, which already leads to very high sim times on my rig.

More info on parameters:

SetVertexTrianglePositionTargeting:
Position Target Stiffness: 30.0
Search Radius: 0.8

SetFleshDefaultProperties:
Density: 100
Vertex Stiffness: 100000.0

Transfer Vertex Attribute:
Transfer Method: Global Transfer

I would really appreciate any advice or steps to take, my degree kind of depends on me making this work.

Biggest of thanks.

(Edited to replace the screenshot with a better legible one)

Hi, the clipping problem is generally because of the lack of constraints (either too few or too weak). To fix this I recommend increasing the spring stiffness between the muscles and the fat layer in SetVertexTrianglePositionTargeting. In an extreme bending case like this, I’d also suggest building kinematic constraints between the fat layer and the skeleton using the kinematic mode in SetFleshBonePositionTargetBinding. Also setting the mass and stiffness of fat layer to be much less than the muscles might help driving the fat layer, for example, using fat mass 100 and stiffness 10K vs. muscle mass 1000 and stiffness 100K.

Thank you so much for your prompt answer, I’ll try these approaches!

Thank you for the kind tutorial.

Question regarding Curve Driven Muscle Activation.
The Witcher 4 demo is described as using both length-based muscle activation and curve-driven muscle activation.

However, the two are very different in the animation assets they use and how they are used, so it doesn’t seem like they can be combined into the same ML Deformer.
How does the Witcher 4 demo use these two together?
Or does it mean that you use length-based for in-game motion and curve-driven for sequencer motion, and so on?

Hi, you can use multiple ML Deformers on the same skeletal mesh and that is how we applied both length-based and curve-driven muscle activation layers. ML Deformers essentially apply vertex position delta and combining them is straightforward.

Hi, is there a simpler way to adjust body fat, similar to what you demonstrated in your SIGGRAPH 2024 paper?

Hi, unfortunately there’s no exactly the same method (a linear blend between the inner and the outer fat surface) to dial the body fat percentage in Chaos Flesh now. During a simulation, you can inflate/deflate the volume of the fat layer using VertexInflation parameter in SetFleshDefaultProperties node.

Hello, thank you very much for the very informative tutorial.
I tried it right away, but I ran into an issue with the ML Deformer step.
Looking at the Output Log, it seems there is an error indicating that torch cannot be imported.
Do you know what might be causing this?

For reference, in UE 5.5 I did not get any errors when running import torch, but in UE 5.6, the error appears.
The Python Foundation Packages are enabled.

Is there a solution to this?

LogStreaming: Display: FlushAsyncLoading(447): 1 QueuedPackages, 0 AsyncPackages
LogActorComponent: RegisterComponentWithWorld: (/Engine/Transient.World_1:PersistentLevel.Train Base Actor_0.DebugSkelMeshComponent_0) Already registered. Aborting.
LogPython: Training the Neural Morph Model
LogScript: Error: Script Msg: Traceback (most recent call last):
  File "E:/UnrealEngine/UE_5.6/Engine/Plugins/Animation/MLDeformer/NeuralMorphModel/Content/Python/init_unreal.py", line 24, in train
    import neuralmorphmodel_local
  File "E:\UnrealEngine/UE_5.6/Engine/Plugins/Animation/MLDeformer/NeuralMorphModel/Content/Python\neuralmorphmodel_local.py", line 6, in <module>
    import torch
ModuleNotFoundError: No module named 'torch'
LogScript: Error: Script call stack:
    /NeuralMorphModel/Python/init_unreal_PY.NeuralMorphPythonTrainingModel.Train
LogMLDeformer: Display: Training duration: 00:00:00 (HH:MM:SS)
LogNeuralMorphModel: Display: Loading Neural Morph Network from file '../../../../../UnrealProjects/RnD56/Intermediate/NeuralMorphModel/NeuralMorphModel.nmn'
LogStreaming: Warning: Failed to read file '../../../../../UnrealProjects/RnD56/Intermediate/NeuralMorphModel/NeuralMorphModel.nmn' error.
LogNeuralMorphModel: Error: Failed to read file '../../../../../UnrealProjects/RnD56/Intermediate/NeuralMorphModel/NeuralMorphModel.nmn'!
LogNeuralMorphModel: Error: Failed to load neural morph network from file '../../../../../UnrealProjects/RnD56/Intermediate/NeuralMorphModel/NeuralMorphModel.nmn'!
LogSlate: Window 'Training Results' being destroyed
Message dialog closed, result: Ok, title: Training Results, text: Training completed but resulting network couldn't be loaded!

(post deleted by author)


So I am really at a loss, whatever I try, my muscles will not be inserted into the muscle activation group, thus making it impossible to activate them.
Help would be hugely appreciated, I have no idea how to go about this. I have gone through my nodes multiple times, what could possibly cause this?

I rebuilt it twice, the second time it worked for a little. After adding another muscle more/painting an insertion/origin, I received an error message that the ComputeMuscleActivationNode needs to be re-evaluated and it suddenly lost the input again. I have no idea whether it has to do with the amount of muscles or if is a specific muscle causing the error.

Hi, you can first validate your muscle fiber field by checking the blue-red color gradient or using VisualizeFiberField node. Make sure you paint on the skeletal mesh collection and transfer the attributes instead of directly on the tetrahedral mesh to avoid accidental topology change.
Next make sure ComputeMuscleActivationNode adds the correct number of muscles to the muscle group in the collection spreadsheet tab. If not, check your log for failure messages. For example, if a muscle has only origin painted but not insertion.