Virtual Bones

Virtual Bones

Inside the Skeleton Editor, you can add Virtual Bones to the existing skeleton of your mesh using the Skeleton Tree. These serve to help improve iteration time by enabling you to change your target joint hierarchy for aiming or IK (inverse kinematics) from inside the Editor. Before this was possible, you would have to add these bones in your 3D modeling software outside of the Editor and then reimport all the animations to fix the animation data with the new joints included.

Virtual Bones, by their very nature, are not skinnable and are constrained between two existing bones in the skeleton hierarchy and they automatically generate data for each animation. For example, you can add a joint that is a child of the hand but is constrained to the palm joint. Unlike sockets, this joint can be used in Animation Blueprintsas a target, such an IK target or "look at" target. These could even be modified in an Animation Blueprint for later use.

Master Pose Component

The Master Pose Component is a Blueprint callable function that enables you to set a Skinned Mesh Component Object (or Skinned Mesh Component Objects) as children to another Skinned Mesh Component Object considered to be the Master. For example, you can define the Torso as the Master Pose Component, assign an animation to the Torso, then add Feet, Legs, Hands and a Head as Children which will follow the animation assigned to the Torso. 

Behind the scenes, the children do not use any Bone Transform Buffer and won't run any animations even if you set them on the Child, it only uses the Torso's Bone Transform Buffer when rendered which makes it a very lightweight attachment system. Only component that has to run animation is the Torso, and all attached components will use the Torso's Bone Transform (below is an example setup where we have assigned an animation to the Torso). 

MasterPoseComponent_01.png

Above, we use the Construction Script inside a Blueprint to set the Torso Skeletal Mesh as the Master Bone Component and the other aspects of our modular character as children.

Each aspect of our character is a Skeletal Mesh that we can change out with another Skeletal Mesh Component. 

HiddenComponents.png

Above, we have toggled the display of the Torso and the Feet (we could change these out with different Skeletal Meshes that follow the same Skeletal hierarchy). 

One thing to consider is that this does not reduce the render cost. You will still render the number of components separately (and more draw calls if you have more sections for each), but it does reduce the game thread cost. 

There is also the limitation that any children of the Master Bone has to be a subset with the exact matching structure, you cannot have any other extra joints or skip any joints. Since there are no Bone Buffer data for extra joints, it will render using the ref pose. You also cannot run any other animations or physics on any children. 

Copy Pose From Mesh

Copy Pose From Mesh is an AnimGraph node that you can use on the Animation Blueprint of the child and allows you to copy the animation pose from any Skeletal Mesh Component. 

Copy Pose From Mesh.png

Copy Pose From Mesh will only copy the bones that match, everything else will use the reference pose. However, you can play animation on top of the copied transforms as illustrated above. 

When using Copy Pose From Mesh, you will also want to make sure that the Skeletal Mesh Component you copy from had already ticked, otherwise you will copy the last frame's animation. For example, say you are copying from the Body and the Head is the Child. To ensure the Body has ticked, you can attach the Head to the Body, which will ensure the parent ticks first before the child. 

You could also set the relationship in code. If you set it as a prerequisite, it will ensure ticking them prior to the current component. See the Tick Dependency page for more information. 

Some elements to consider when using Copy Pose From Mesh is that it is more expensive than Master Pose because this runs animation on each child. Additionally, if you want to use physics on the child, you may want to use the Rigid Body or AnimDynamics skeletal control nodes.

When previewing animation in the Animation Editor, you can assign additional meshes that will automatically use Copy Pose From Mesh. Also you can create a custom Preview Mesh Collection that you can use to build collections of related Skeletal Meshes that are animated together (such as the components of a character). Below we illustrate how to change and and assign different Skeletal Meshes to our preview enabling us to swap out different heads on our character. 

Skeletal Mesh Merge

At runtime you can merge multiple Skeletal Meshes into a single Skeletal Mesh through code with FSkeletalMeshMerge. While this has a high initial cost of creating the Skeletal Mesh, the rendering cost is cheaper since you are rendering a single Skeletal Mesh instead of multiple meshes. For example, if you have a character comprised of three components (head, body and legs) and you have 50 characters onscreen, this would result in 50 draw calls. Without Skeletal Mesh Merge, each component has its own draw call resulting in three calls per character or a total of 150 draw calls

When using FSkeletalMeshMerge, your main "body" has to contain all the animations because the merged mesh will only use the Skeleton that's set and it has to contain all the joints you'd need to animate. If you have extra joints for certain body parts, you still have to have all the animations on the body. Other things to consider, you can only run one animation on the merged mesh and transferring Morph Targets to the merged mesh is not supported. If however you look at FSkeletalMeshMerge::GenerateLODModel, once you have your Skeletal Mesh you can create your morph targets by calculating the FMorphTargetDelta between your base mesh and any morphs. 

Additionally when using FSkeletalMeshMerge you will likely need to build your content in a specific way from the start. You'll want to use one common Material and decide on an atlas for your textures (for example, boots go in this region while gloves go in this region and so on) so you can also cut up and put together your textures to make new ones and render your whole character as one section. 

Additional Resources

For additional information and suggestions for practical usage of Virtual Bones, like how they have been used to make retargeting easier, to change reference frames for controllers, for orientation, and slope warping.