Morph Tools Plugin - WIP
Current Feature List Overview:
- Morph Baking in Editor
- Via a custom asset and morph editor
- Morph Baking at Runtime
- Combine multiple morphs into a single morph (Editor Only)
- Copy morphs from one mesh to another. (Editor Only)
- Export morph target presets and set them at run-time with handy blueprint functions.
Feature 1: Morph Baking in Editor
What do i mean by bake? I mean permanently apply the deformation of the morph target the the mesh data, and optionally remove the morph target entirely.
Why would I want to do this?
The characters in my game have a lot of “set and forget” morph targets, e.g nose size, body size, or other things that don’t change over time. Since morph targets can cause performance drops if you have a ton (which i did), I made this system to lighten the load. My test character (exported from daz) has roughly 2000 morph targets and consumed tons of memory. With this system i can set the morph targets once on load and then immediately bake them and remove them from the mesh entirely. Cutting down the mesh size by hundreds of MB. This is an extreme scenario.
In Editor Morph Baking Overview
Once the plugin is installed, you can create a new “Morph tools Asset” by right clicking anywhere in the content browser, or by right clicking any skeletal mesh.
Once created you can pick a default skeletal mesh to start working on, and then you can open up the asset and you will be presented with the Morph Tools Editor.
Once opened, there are 4 Panels in the Editor. You will generally want to un-dock these and make them full screen in order for them to display properly.
- Copy Panel (see morph copying section)
- Meshes Panel
- Bake Panel
- Morphs Panel
The morphs panel is where you set the values of the morphs before you bake them. You can see the effect in the morph tools viewport window.
bake: Bake the deform of the morph into the mesh at the current weight
remove: Remove the morph from the mesh after baking
blacklist: do absolutely nothing to this morph.
Once you have everything set the way you like it, you can either save the asset to finish settings the morphs later, or click the “Bake Morphs” button the in the bottom of the Baking Panel (see bake panel section). The baking process does not effect the original mesh, it creates a new version in the output directory you specify.
You can also export the current morph settings as a preset and import them into another Morph Tools Asset so you have a base to start from rather than starting fresh each time.
Feature 2: Morph Baking at Runtime
Most important for me was runtime Morph baking. My test character meshes have over 2000 possible morphs, and i needed the ability to customize characters at runtime via a character generator.
For runtime baking, simply set the morphs you want on your character via Set Morph Target, then call this blueprint node. It can also be called via c++.
The example project shows a simple scenario where you can see how I set it up.
The Bake Morphs function takes in a SkeletalMeshComponent with morphs applied to it, and uses the bake settings array passed to it to determine which morphs to bake and remove, and which morphs to ignore. If bake settings is empty it will bake and remove ALL morphs.
For an more complete example of how to bake them at runtime, see the example project.
Feature 3 & 4: Morph Copying and Morph Combining
Morph copying and combining is handled from the “Copy Morphs” Panel:
Morph copying from one mesh to another is accomplished by creating a proximity map that maps the vertices on the “target” mesh, to the closest vertices on the “source” mesh. A proximity map asset is created when you click the copy morphs button, and can be reused instead of creating a new one if you need to run the same operation again. The proximity map is generated using a k-d tree, and the closest vertices are found using the k-nearest-neighbors algorithm.
The target mesh is whatever mesh you currently have selected in the morphs panel. You pick the source mesh using the first button under “setup”.
Morph copying and combining is currently editor only.
For a deeper explanation of all the controls on the copy panel, see the video.
The example project contains a very basic example of how you might want to set up your morph presets and characters. Its very simplified and you will likely want to come up with some more sophisticated for your game. I will go over the sample project in the video.