Cannot use morphs with cloth simulation

Currently, it is not possible to use morphs on a skeletal mesh section with cloth simulation enabled. As per the following snippet in FSkeletalMeshObjectGPUSkin::ProcessUpdatedDynamicData (SkeletalRenderGPUSkin.cpp):

const bool bSectionUsingCloth = GEnableCloth && ClothVertexFactory != nullptr;
const bool bSectionUsingMorph = Mode == EGPUSkinCacheEntryMode::Raster && MorphVertexBuffer && !bSectionUsingCloth && (bHasExternalMorphs || (bHasWeightedActiveMorphs && DynamicData->SectionIdsUseByActiveMorphTargets.Contains(SectionIdx)));

If a section has cloth simulation enabled then bSectionUsingCloth will be true and bSectionUsingMorph will be false.

Commenting out “&& !bSectionUsingCloth” in the second expression appears to work as intended in a quick test - the section gets deformation both from cloth simulation and morphs. However, I imagine there are technical reasons for this restriction (which appears to have been there for a long time, even in UE4 already).

For context, the use case for this is using cloth simulation for large scale cloth deformation (such as flapping) and morphs (an external morph set from an ML deformer, really) for details (wrinkles, etc.). Each system would likely be used on different parts of the mesh, so a fallback could be to split it in more sections, but it would be great if you could have them together so you could blend from one to the other smoothly.

Edit: Just as additional information, the result is the same whether using the default deformation pipeline or a deformer graph.

Hi Javier,

I’ve reached out this the devs and although this is a feature we’d like to have as well, it is not on our roadmap currently.

The feeling is that there would be a fair bit of work to get this working well (comment below from dev)

If they just want a simple blend, there are two properties that allows a blend between the skinned and cloth deformed render vertices:

  1. The cloth blend weight on the Skeletal Mesh Component.
  2. The smoothing data baked in the cloth deformer mappings. It can be painted in the Cloth Asset graph, but when using the legacy cloth system it is a simple smoothing calculation done on the kinematic vertices’ boundaries.

So theoretically they could blend between the sim deformed mesh and the morph deformed mesh.

All the best

Geoff Stacey

Developer Relations

EPIC Games

Hello Geoff,

Thank you for your reply.

Regarding the comment from the dev that you added, I just wanted to confirm whether they are referring to a setup with a custom deformer graph. I did try using a deformer graph to blend between the simulated mesh and the morphs using the cloth blend weight as suggested, but still found that the data coming out of the “Morph Target” deformer graph interface was not being filled.

Again, the only way I have found to get it to work is by modifying the aforementioned lines of code. Right now I have changed it from this:

const bool bSectionUsingCloth = GEnableCloth && ClothVertexFactory != nullptr;
const bool bSectionUsingMorph = Mode == EGPUSkinCacheEntryMode::Raster && MorphVertexBuffer && !bSectionUsingCloth && (bHasExternalMorphs || (bHasWeightedActiveMorphs && DynamicData->SectionIdsUseByActiveMorphTargets.Contains(SectionIdx)));

To this:

const bool bSectionUsingCloth = GEnableCloth && ClothVertexFactory != nullptr;
const bool bCanUseMorphsWithCloth = DynamicData->GPUSkinTechnique == ESkeletalMeshGPUSkinTechnique::MeshDeformer;
const bool bSectionUsingMorph = Mode == EGPUSkinCacheEntryMode::Raster && MorphVertexBuffer && (!bSectionUsingCloth || bCanUseMorphsWithCloth) && (bHasExternalMorphs || (bHasWeightedActiveMorphs && DynamicData->SectionIdsUseByActiveMorphTargets.Contains(SectionIdx)));

So combining cloth simulation and morphs would only be allowed in deformer graphs.

Can you confirm if this goes along the lines of what the dev was suggesting?

Many thanks,

Javier

Hi Javier, I am the dev who gave the Cloth Blend Weight info to Geoff.

Your change looks safe to us, but I’m ensure whether the Cloth Blend Weight would work in that case.

We haven’t done a lot of cloth simulation through the custom deformer graph, as we usually either use the fixed render pipeline with cloth, or do ML deformer cloth.

It has most likely never been tested, therefore that is something you will probably have to try on your side.

I’ll let you know if I find some more info about this.