Exporting models from Blender to Unreal Engine 4
A while back, when I was creating my own 3D engine, I started using Blender for my modelling needs. At the time, Blender 2.4 was very strange to me, being used to modelling with 3DS Max. I didn't like it then, but since I didn't have the money to buy the 3DS Max, I had no choice. Fortunately, as I got more and more used to it, and had a good impression creating my add-on to export the models to the format I used in my engine, I started to like it.
I stopped modelling for quite some time, but then recently I had the need to create 3D models again. So, it was time to choose the 3D modelling program again. Surprisingly, I really felt at home with Blender, now at version 2.7, with a much better interface. So I decided to use it again.
Unfortunately, Unreal Engine 4 works only with FBX, and only offers nice integration with plugins for Maya and 3DSMax. So, to use Blender, I had to learn how to configure it so I can use the models inside UE4 with no surprises while importing.
Setting up the start-up file
I don't like to change all the settings every time I create a new model, so the best option is to setup the Blender start-up file. Starting Blender and creating a new file, the first thing I like to do is delete all the default objects (the camera, cube and light).
Then, I configure the unit settings. UE4 uses centimeters by default. I saw some modellers adjusting the unit scale at export, but it may make exporting models and skeletons in the same file harder. To set the global unit scale, I go to the "Scene" tab inside the Properties view, then I select the "Centimeters" preset in the "Units" area. Done.
The last thing to do is to create an "Export FBX" preset. Using the default preset as a starting point, I change the following options:
-
Main tab:
- Check Selected Objects;
- Forward: to -Y;
- Up: to Z;
- Right below, I only leave checked the Empty, Armature, Mesh and Other;
-
Geometries tab:
- Use Modifiers Render Settings unchecked;
- Smoothing set to Faces;
-
And finally, the Armature tab:
- Unset Add Leaf Bones;
- Primary Bone Axis to X Axis;
- Secondary Bone Axis to -Y Axis;
The reason to change the Armature axis is to make them match the same axis orientation that the engine, that uses the positive X axis as "forward" and the Z axis as "up". That way, you can use the bones as sockets directly, not having to correct the rotation.
Finally, we press Ctrl+U, or in the File menu, select Save Startup File.
Details before exporting the model
Firstly, check with the Triangulate modifier if all the faces of your model are being transformed to triangles in a satisfactory way. Sometimes, faces can have non-coplanar vertices, which can result in unexpected triangulation and/or tangent calculation errors, which leads to shading errors. In this case, it's better to manually triangulate or use the "make planar" function in the Clean-up edit mode menu.
Next, the model need to be oriented depending on how it'll be used in the engine. It helps to make your model face the positive X axis if it is a projectile, or other object that will mainly travel forward after being spawned. While the engine can do that rotation when importing, it won't work on models with skeletons, since the orientation of the animations will be different from the "corrected" orientation.
Import options in the Unreal Engine 4
Generally, the option that should be used for all the models is the import of normals and tangents. Since both Blender and UE4 use the same tangent space, MikkTSpace, the model can be rendered in the engine as close as it was in Blender. This is most important when importing models used with skeletal animation because it's the only way you can preserve smoothing groups.
Recommended Blender Add-Ons
uvmap_tools - A tool to organize UV layers.
YAVNE - Add-on to manually calculate normals for low or medium complexity models. Excellent for mechanical models, allow the creation of rounded edges using only one face.
mesh_curves- Generate curvature information and saves it into vertex colors. Great for using this information to create complex materials, vertex based ambient occlusion, etc.