Exporting Blender models for Godot

Dec 19, 2020

This is the workflow that I’m using to export Blender assets to Godot for Dogrun.

I’m developing on linux and these are the versions of software that I’m using at time of writing:

Install godot-blender-exporter

wget https://github.com/godotengine/godot-blender-exporter/archive/master.zip
unzip master.zip
mv godot-blender-exporter-master/io_scene_godot/ ~/.config/blender/2.83/scripts/addons/

Then in blender Edit > Preferences > Add-ons and check Import-Export: Godot Engine Exporter.

Preparing for export

Tris/quads

You will get an error like: Tangent space can only be computed for tris/quads, aborting if you attempt to export a mesh with a face that has more than 4 verticies.

Find and fix this by entering Edit Mode then Select > Select All by Trait > Faces by Sides.

select faces by sides

and choose Greater than 4 verticies.

select faces with greater than 4 verticies

Now that the offending faces are selected, click Faces > Triangulate Faces and this will split our n-gon faces into triangles.

triangulate faces

https://blender.stackexchange.com/a/55608 has a nice complete explanation about fixing these issues in general.

Vertex Weights

Before exporting you need to limit number of weights per vertex to 4.

vertex weight paints

Use the Weight Paint mode and select Weights > Limit total then enter 4.

limit total

limit number of weights per vertex to 4

If you are using modifiers you actually need to run this after the modifiers are applied.

While the export plugin has an option to “Apply Modifiers”, the weights after applying the modifiers may exceed 4. Apply the modifier yourself then limit weights before exporting.

apply mirror modifier

Armatures and Animations

I build the animations for my dog model by creating multiple “poses” and adding them to the Pose Library. Then in the Action Editor I created a number of animations that I then “stash” as a “non-contributing strip for later use”.

I get the cleanest exports by ensuring that I only have animations in the “Action Stash”.

Go to the Nonlinear Animation editor in the Animation Workspace to verify that all animations are in the “Action Stash”.

select nonlinear animation editor

Here we see that the beg animation is active and not in the stash.

beg track is not in action stash

We fix that by returning to the Action Editor and pressing the Stash button.

stash beg action

Returning the to Nonlinear Animation editor I now clear out all actions other than the stashed actions.

delete wagging.001

Select strips and delete them:

delete strips

Then delete NLA tracks and Remove Empty Animation Data.

remove empty animation data

The result is a clean rig with each animation in its own track:

clean animations

See https://www.youtube.com/watch?v=weMes839wlc for more information on NLA and Actions.

Export Settings

I use these settings to export the character.

scene export stashed actions, animations

When importing I want:

  • The material to be its own file - this is useful to re-use materials across models.
  • The mesh to be its own file - this is helpful when a node nees to reference the mesh directly (like a MultiMeshInstance)
  • The scene to have a rig with a child AnimationPlayer where each Action is its own track. I use “built-in” storage here as I haven’t found separate files to be of much help (although adding animations does require re-importing).

I’ve found that the Import with separate Objects and Materials preset to be a good starting point:

godot import preset

Conclusion

So that is my current process! Hopefully this helps others looking to use Blender and Godot or at least help me remember later!

Be sure to check back here or follow me on twitter @tam7t to get the latest on Dogrun progress!


Tags: