I just visited the Ue4 roadmap on Trello and I was surprised that I didn’t see a node for “Customizable Characters using FSkeletalMeshMerge and Texture atlases”. I hope you find this post useful and I will be most grateful for your support! Please reply if you want to see content examples, documentation and videos.
Customizable Characters using Mesh Compositing Advantages explained:
50 draw calls! ( this is ideal for multiplayer games!)
For multi player games,Mesh compositing (using FSkeletalMeshMerge) is the better choice for customizing characters. In example, if you have a multiplayer game where many people have unique armor, each component mesh of the character(helm,chest,arms, pants for instance) is combined and the engine only has 1 draw call. So, if you have 50 characters on the screen, the meshes are only 50 draw calls.
250 draw calls! ( this is not good for multiplayer games!)
The other option for customizing characters doesn’t appear to be efficient for multiplayer games. The other option is adding all the meshes into blueprints as components. Each component mesh as a draw call, so if you had 4 pieces of armor and 1 body mesh, this would be 5 draw calls just for the meshes! For 50 players, this would be 50 players x 5 meshes each=250 draw calls!
I’m really hoping the community is interested as much as I am, since I haven’t seen any marketplace content, documentation or videos on FSkeletalMeshMerge.
I hope you have found this post useful and I will be most grateful for your support! Please reply if you want to see content examples, documentation and videos!
I’d be interested in this.
my UDK game’s characters are composed of 9 body part meshes + a variable number of cloth and armor (anything from 2 to 10), and they are all using one ParentAnimComponent (same skeleton). when the time comes to make the move to UE4 I’ll most likely implement multiplayer, or at least a much larger amount of AI characters on-screen.
I’m curious as to how this would affect Morph Targetting though. ideally my head meshes will have morph targets but the rest wouldn’t. still if I could merge all meshes excepting the MorphTarget’d mesh it’d be huge.
I also wonder if it’s as good and great as you describe it. on paper you could reduce the drawcall amount… but only if all the meshes use the same materials. a single mesh with 2 different materials already produces 2 draw calls, so how does merging 2 skeletalmeshes with different materials (ie. body and armor) reduce the drawcall amount? all I see is it would reduce the processing time for the skeleton transform, but maybe I’m missing something?
1 Mesh and 1Material are 2 different draw calls no matter what you use. FSkeletalMeshMerge uses texture atlasing, from what I gather, this would be optimized from using regular multiple materials as well.
If anyone is familiar with UE3’S MODULAR pawn documentation, you may note that it never went into depth about how animtrees operated with each separate skeletal mesh. Making a blended animations were required for each piece of the armor. With FSkeletalMeshMege, this would be simplified greatly with only one mesh!
Your numbers don’t quite add up, in your example it’s 50 draw calls vs 250 draw calls So you have saved 200 draw calls, but you have added a lot of complexity to your pipeline. All character and armor meshes now have to use a common base material. You have to be very specific about UV layout, and features like morph targets or material parameters are harder to use.
There are certainly cases where mesh merging is helpful or even necessary, but we feel for a lot of games, the better tradeoff is to use multiple skeletal components. We do want to have some good examples or tutorials on that, and we are discussing here quite what we want to do. Once we have that covered, we probably will try and cover merging, but for the reasons mentioned above, it is a little lower priority.
Have you tried using the existing FSkeletalMeshMerge code?
Thank you for taking the time to respond, I know you are very busy working on UE4 and I appreciate your time. You are doing a Fantastic job, the engine is unreal!
Just a heads up, I really value your post, I was merely trying to see if other “users” were interested. I realize using mesh compositing is the more difficult path, but it obviously has it’s trade offs. I was not aware that morph targets and material parameters were effected. Yes, I agree that Adding components has a faster development time (exponentially) and it’s easier to understand.
Can you please briefly describe why using morph targets and material params with FSkelMeshMege is more difficult? How are animations effected?
I am really looking forward to the customized character documentation that you speak about above :), great work so far! thank you for all that you have done on UE4, it’s really a fantastic piece of art (it’s unreal!).
Have a great night.
I’ve corrected the math typo above,(it should have been 50 vs 250).
Material parameters are hard because you have to apply one MID to the whole mesh, which means you need multiple mask textures if you want red gloves and blue trousers. If you have multiple components, you can have one MID per piece, which makes it easier to modify colours etc.
Morph targets are tricky because they map to vertex indices. You would need to add an additional step to duplicate the morph target data when you merge the meshes and remap the verts to the new target mesh. That code doesn’t exist yet.
actually I’m quite familiar with UE3’s modular pawn system, and I know that animating multiple parts was very easy. the only requirement was that the skeleton for all parts was exactly the same in your 3d package
my workflow was like this: rig and skin all of the body parts together (only done once) using 3dsmax’s Skin modifier (using envelopes, not painting vertices). for every new cloth/armor part, put it on top of the main model and copy-paste the Skin modifier. export. done.
since UE3 allowed the use of a ParentAnimComponent only the first body part needed an AnimTree assigned, while all the others would use the one from the first one via the ParentAnimComponent property
: does this then mean that atlases are not created automatically?
I find merging meshes to be way better than a modular pawn because the shadow outlines arent separate like they are when having multiple SkeletalMeshComponents, and its probably much more performant (other than at load time when the merging occurs) because there’s only one SkeletalMesh being animated/rendered (I don’t know what they are talking about texture atlases and stuff, you can have multiple materials per SkeletalMesh !)
Here’s the code for a component which has an editable SketetalMesh piece list (in the editor), and generates the mergemesh on creation time:
/** Component that contains multiple SkeletalMeshes as a single unit */
UCLASS(editinlinenew, meta=(BlueprintSpawnableComponent), ClassGroup=Rendering)
class UCompositeModelComponent : public USkeletalMeshComponent
UPROPERTY(EditAnywhere, Category = "Pieces")
void OnRegister() override;
void OnUnregister() override;
Please note, that the FSkeletalMeshMerge thing supplied with UE4 identifies materials on the input meshes by their UMaterial*, so make sure you have a default material properly set on all the source SkeletalMeshes, otherwise the output MergedMesh will be all the same material (as all input UMaterial* are nullptr). I think this is a bug and should be fixed (it should identify by source material ids, increasing for each source piece, this would make the output material list in a predictable order as well).
You can use the ‘bLightAttachmentsAsGroup’ property on the parent component to shadow it and all attachments as one group, which will prevent the shadow artifacts (and improve performance). You can use the ‘SetMasterPoseComponent’ function to only animate one ‘master’ skeletal mesh and have others just use its animation. The main reason for merging meshes it to reduce section count in your scene. If you don’t combine textures when you merge, you won’t actually be reducing your section count. 1 mesh with 5 materials or 5 meshes with 1 material each are both 5 ‘draw calls’. I hope that helps clarify a bit!
Hey so for anyone interested I created a plugin for merging meshes as in the ue4 docs the code for doing so is kind of outdated if you are interested you can download the plugin from my github as for now for ue4.21
Here is the link:
One problem I haven’t been able to take care of is the matter that when one of the body parts is a cloth part it won’t be simulated as cloth after merging together.
If I get any updates on this I will inform you.