GameUE4

Importing a Maya Blendshape Animation Into UE 4

By 13. September 2017 April 10th, 2018 No Comments

Create a Blendshape animation in Maya and import it into UE4. Create a screencast with the Sequencer.

For making blendshapes work, the number and structure of vertices must not change during the animation. Start with a simple cube to sphere morph as described below or you can use any other (simple) geometry for the animation.

Creating a Blendshape in Maya

  • In Maya > Create > Polygon Primitives > Cube and in the Modeling Toolkit > Add Divisions 2 times. Rename it to “cube”. Apply a texture map.
  • Duplicate this Object in the Outliner (CTRL-D) and rename it to “target”. Hide the first cube with the h key. Now > Create > Polygon Primitives > Sphere, rename it to “helper” and scale it smaller, so that it’s completely covered by the cube.
  • First select the “target” and then the “helper” and in the Modeling menu set select >  Deform – Create > ShrinkWrap [options]. Make sure > Projection > Toward Inner Object is selected, click Apply. The former “target” cube should have now a spherical shape and lie inside the “helper” sphere. You can hide the “helper” with the h key (don’t delete it yet).
  • With the “target” selected > Edit > Delete by Type > History. Now you can delete the “helper” object.
  • Unhide the first cube with the “h” key. Select the “target”, scale it up to roughly equalise the cube’s and the sphere’s volume. With the “target” and the “cube” selected > Modify > Freeze Transformations.
  • Select first the “target” and then the “cube” (the morph’s initial state is selected last), select >  Deform – Create > Blend Shape [options]. Make sure that Check topology is marked, click Create.
  • Hide the “target”, but don’t delete it. With > Windows > Animation Editors > Shape Editors or in the blendShape tab at the Attribute Editor you should be now able to change the target weight, so that the shape morphs from cube to sphere. Set a keyframe at frame 0 with a target weight of 0 and at frame 200 with a target weight of 100.
  • With the “cube” selected go to > Mesh Display > Soften/Harden Edge [Options] type in an angle of about 45 and > Apply. This softens the edges in accordance with the state of the shape.

Exporting the Blendshape from Maya as FBX file

  • With the “cube” selected > File > Export Selection … In the FBX Exporter dialog make a tick at > Geometry √ Tangents and Binormals, at > Animation √ Animation and at > Deformed Models √ Deformed Models, √ Skins and √ Blend Shapes.

Importing the FBX file into UE 4

  • In UE4’s Content Browser select > Import. In the FBX Import Options make a tick at √ Skeletal Mesh. Expand the > Mesh tab and check √ Import Morph Targets and at > Normal Import Method choose Import Normals and Tangents. Make sure that Animation is checked and change at > Transform > Import Uniform Scale to 100 if you haven’t scaled your model in Maya yet.
  • From the Content Browser open the newly imported Animation Sequence (filename_Anim). Due to a bug in UE 4.17.1 the Blendshape animation might not work yet. To fix it, select the imported Skeletal Mesh in the Content Browser and with RMB choose > Reimport.

Exporting the Blendshape from Maya as Alembic file

  • With the cube selected go to > Cache > Alembic Cache > Export Selection to Alembic [Option].
  • At > Advanced Options you need to check √ UV Write and √ Write UV Sets. Export Selection.

Importing the Alembic file into UE 4

  • In UE4’s Content Browser select > Import. Make sure that in the Alembic Cache Import Options at > Alembic > Import Type > Skeletal is selected. Recompute Normals should be deselected. > Conversion > Scale your model by 100 if you haven’t done it in Maya yet. Make sure, the y – scale value remains negative (to compensate the different axis orientation in Maya and UE4).
  • You can double click on the newly created …_Animation asset to see if the animation works. Drag it into your scene.
  • In UE4’s Content Browser select > Add New > Material and rename it. Double click the newly created Alembic Skeletal Mesh node. In the editor at > Material Slots select this material from the dropdown menu.
  • In the Content Browser select > Import and choose the texture file from your drive you want to apply.
  • Double click on the Material. Drag the imported texture onto the Material editor. Connect the topmost white connector from the Texture Sample with the Base Colour connector of your Material node.
  • If you want to change the specularity of the material, create a simple colour node. RMB click, type: const and select Constant3Vector. Connect the output with the Specular input. Duplicate the colour node and connect it with the Roughness input. If you want full specularity, change the colour node at the specular input to white and leave the one at Roughness black. White = 100 % Specular, Black = 0 % Roughness, you can fine tune the specularity values with different greyscale values.
  • Click the > Apply icon on top of the Material Editor. When the Material is assigned to your alembic file, it should show up in the viewport after a while. In case the material disappears while playing the game / animation, save the project and open it again to refresh the texture cache.

Editing with the Sequencer

  • Go to the Modes Window / Tab and from the Basic tab drag an empty actor into the viewport. This creates a null object which we ca use for a simple camera rig to let the camera rotate around. Move it to the focal point in your scene and in the World Outliner give it a meaningful name.
  • In the Modes Window / Tab type “cam”. Select the simple Camera on top of the list and drag it into the viewport. While the camera is selected you get an preview in the viewport. Move the camera until you are satisfied with the framing.
  • In the World Outliner drag the Camera onto the null object to make it a child of the null.
  • In the top toolbar choose > Cinematics > Add Level Sequence. Specify a name and path. It will then show up in the World Outliner.
  • If there is a Camera Cuts track in the Sequencer, delete it. Create > + Track > Camera Cut Track. In this track add  a > + Camera. From the dropdown menu select the camera you want to use and make sure the track covers the whole timeline.
  • You could also add different cameras and control with their track duration in the Sequencer which camera will be used in the final animation.
  • To animate the rotation of the camera around the focal point, drag the null object into the Sequencer. Expand it’s > Transform > Rotation tabs and by clicking on the little circle set a keyframe at frame 1 for the z value (in UE4 the axis are flipped, Maya’s y axis is equivalent to UE4’s z axis). Go to the end of the animation and type in 170 for z. A keyframe will be created automatically.
  • You might have noticed that values beyond +/- 180 degrees are not accepted here. In the the top menu of the Sequencer on the right click the animation curve icon to show the animation keys in a curve editor. When you select the key there, you can type in any value without restriction.
  • If you close your UE4 project and want to continue working with the Sequencer you need to RMB click on the sequence in the World Outliner and choose > Edit LevelSequence or press CTRL-E (double click doesn’t work here).

Exporting the Animation

  • In the sequencer window click on the clapper board icon to open the Render Movie Settings Menu.
  • Use Video Sequence as Output Format, change Frame Rate and Video Resolution, disable Use Compression to avoid compression artefacts.
  • In the Cinematic tab make sure Cinematic Mode and Cinematic Engine Scalability are checked.
  • > Capture Movie and convert the output .avi file with Adobe Media Encoder to .mp4.

Quick Tips

  • Improve shadow quality and remove the preview mark on materials: Select Light Source and in the Details pane select  > Transform > Mobility > Movable (instead of Stationary).
  • Enable precise physical interactions (e.g. walk on a terrain): In the content browser select the Static Mesh asset. Double click it to open the Editor window. In the Details tab at > Collision > Collision Complexity choose from the popup menu > Change Complex Collision as Simple.
  • Avoid Intersection with other actors: Double click on the static mesh to open the asset editor. At the Details tab scroll down to > Collision and at > Collision Presets choose > BlockAll.