Fully hidden MetaHuman body becomes visible after assembly

Summary

All-black body hiding masks have no effect on assembled MetaHuman characters, and only work in the MetaHuman creator. Assembled characters end up with a fully visible body.

What Type of Bug are you experiencing?

Editor

Steps to Reproduce

  1. Create a project with MetaHuman support enabled.
  2. Create a MetaHuman and rig it.
  3. Take any garment. Import a totally black image and use it as the wardrobe item’s “Body Hidden Face Map Texture”. Leave everything else at defaults.
  4. Fit the character with the garment in the MetaHuman editor. The body should disappear.
  5. Assemble the character and open the generated skeletal mesh.

Expected Result

The body, just as in the MetaHuman creator, is hidden.

Observed Result

The entire body is present and the mask takes no effect.

Affects Versions

5.8

Platform(s)

Windows

Upload an image

Additional Notes

This issue has been plaguing me for some months now. Recently, I got annoyed enough to start digging into the engine source. I think I’ve maybe found out what’s going on?

Looking at the MetaHuman plugin code, there’s a function TryRemoveHiddenGeometry which is what I think is being called to do the work for processing these masks. It in turn calls RemoveAndShrinkGeometry for each LOD.

Now, in MetaHumanGeometryRemoval.cpp, ShouldHideTriangle goes over the mask, and since it’s all black, every triangle is flagged for removal. So then the StrippedImportedData that gets built has no faces.

When removal calls StrippedImportData.GetMeshDescription(), GetMeshDescription in SkeletalMeshLODImporterData.cpp checks if either points or faces are empty before it does anything. In this case, they both are, so it returns false early.

So going back to RemoveAndShrinkGeometry, CreateMeshDescription and CommitMeshDescription only run if GetMeshDescription doesn’t return false. But in this case, it did, since the data had no faces! And therefore, the original body mesh doesn’t get replaced.

I have no idea if my theory as to what’s going wrong is on the money or not, but it’s my best stab at figuring out what the root cause is. I can’t even begin to suggest what the right fix may be as god knows where else this code is being called from and what other responsibilities it has and what its behaviour therefore has to be. But in any case, I hope that my efforts here were at least a little bit helpful.

If anyone runs into this and would like a workaround, so far the only workaround I’ve been able to come up with is to just put some bit of white in the body hide mask on some part of the body that is safely hidden by the clothes and is at low risk of intersecting with the clothing. It’s not pretty, but it seems to work.