- Programming Guide
- Using customizable objects in game
- Internal Design
Unreal Engine modules¶
The system is structured as an Unreal plugin with two additional Unreal modules: one for the editor and one for the runtime. These modules use external libraries for the Mutable runtime, which is a standalonw library with no dependencies.
This is the basic folder structure of an Unreal Engine game that uses Mutable. The hierarchy only shows the relevant folders for Mutable source code.
The folder “source” is optional and it contains the source code of the standalone runtime and tools libraries. These are already included in the “lib” folder as precompiled binaries for each supported platform, with the required headers in the “include” folder. For the debug version, symbol pdb files are also included.
In case the source of the standalone libraries needs to be modified, a Visual Studio solution is included inside source->project->vs2015 to rebuild them. Both “release” and “debug” configurations should always be rebuilt to avoid desynchronising the binaries. After that the libraries and include files need to be updated using the script “DeployFromSource.bat” in the mutable folder.
The “source” folder may also contain the source code for the standalone tools for Mutable. These tools are not required for normal Mutable usage but they can be very helpful to debug and profile your project.
Most of Mutable happens in the plugin described above. However, there are some changes that are required in the engine and tools, than cannot be done from a plugin. These are a small set of changes (usually a handful of lines) and they affect the following files:
- To add an additional cook step to build the CustomizableObject assets:
- To add some texture streaming tweaks for mutable textures:
- To expose at DLL level a required internal method:
- To extend some worker thread stack size:
We aim at reducing the number of this engine changes as our development progresses.
Packaging a project¶
When a project is packaged for distribution, Mutable will compile all the relevant CustomizableObject assets. This compilation step will be done with maximum optimisation so it will take longer than compiling an object in the editor. Additionally, the data used by the CustomizableObjects will be prepared for disk streaming. Thanks to this, the memory usage of your project will be kept low regardless how may options you have in your objects.
In order to package a project using Mutable you need to include an additional folder in the packaging process: <YourProject>/Content/MutableStreamedData . You can do this in the DefaultGame.ini file of your project:
or from the project settings in the Unreal editor:
Using customizable objects in game¶
This helper component can be used with an actor in order to update a SkeletalMeshComponent replacing its mesh asset with a Mutable-generated mesh. The steps to use this component are:
- Create an actor with a SkeletalMeshComponent.
- Add a new CustomizableSkeletalComponent as a child of the SkeletalMeshComponent.
- Assign a CustomizableInstance asset to the CustomizableSkeletalComponent.
- When the actor is added to a level, it should automatically show the customized skeletal mesh.
The Reference Mesh¶
The Reference Mesh is an Unreal SkeletalMesh asset that is used as a template to create customizable skeletal meshes. It is assigned to the CustomizableObject asset.
- All the data that is not related to meshes and textures will be copied from the reference skeletal mesh.
- While a customised skeletal mesh is being built, the reference skeletal mesh will be displayed.
Mutable is designed around the concept of virtual machine. Customizable objects are decomposed in series of intructions that are optimised to build the instances on different situations. These instructions operate on mesh fragments, images and colours and they transform them by merging, blending, packaging texture coordinates etc.
The system relies heavily in a pre-process of the object graph that generates code for a virtual machine whose operations involve mesh fragments, images, etc. This object-construction code is then optimised for every use case of the model so that the optimal process to construct an instance is found.
Mutable standalone model debugger and profiler showing the virtual machine code, the set of constant data (image blocks and mesh fragments), a preview object and texture layout and a simulation of the parallel construction of a model with its memory usage.