Static Meshes

Importing static meshes from Blender into Godot

The following is a general guide for importing static meshes from Blender into Godot. If the assets/modules are to be used as part of the Realm Builder so that they can be shared with the wider community there are additional requirements see Realm Builder

Blender

Sample realm

Working .blend and .gltf files of a full static realm scene that will import seamlessly into Godot can be downloaded here:

Sample meshes

Working .blend files of individual example meshes can be downloaded here:

Exporting process

NOTE: If 3D programs other than Blender are used to create assets it is recommended to import them into Blender first in order to make use of the optimised Import/Export pipeline. Importing into Blender is done via File -> Import where a variety of compatible formats such as Wavefront (.obj) or glTF 2.0 (.glb/.gltf) can be selected. In addition there are many freely available add-ons created by the community for other file formats. If multiple Blender files are to be combined they can be dragged and dropped into the modelling space followed by a prompt and selecting Append -> Object -> File. Importing the Object instead of the Mesh will ensure Blender also imports all associated materials.

The recommended Blender-Godot file format is glTF 2.0 (.glb/.gltf) , specifically glTF Separate (.gltf, + .bin + textures). The glTF export option come with Blender but might need to be enabled via Edit -> Preferences -> Add-ons then search for gltf and check the tickbox.

Prior to exporting meshes, they should satisfy certain requirements to ensure scenes performs well inside the game engine and on a variety of devices.

Mesh optimisation

Vertex count

  • In Blender the number of vertices can be displayed by toggling the checkbox under Viewport Overlay -> Statistics

  • As a rough guide the total count should not exceed 1.000.000 vertices per scene.

  • Remove duplicate vertices by selecting the asset then Edit Mode -> Mesh -> Merge -> By Distance. This function can also be used during modelling by toggling Auto Merge Vertices in Blender.

Face orientation - Normals

  • In Blender the orientation of your mesh can be displayed by toggling the checkbox under Viewport Overlay -> Face Orientation. Blue meshes represent front faces and red meshes are back faces. By default back faces are not rendered inside Godot to save resources therefore ensure all your meshes are correctly orientated.

  • In case a single-surface object i.e. a window pane is visible from both sides in the game, Cull Mode can be disabled in Godot to display both sides.

Materials

  • Each additional material requires an additional draw call in-engine so keep the number of materials as low as possible.

  • For PBR workflows texture images and maps should be no larger than 2048 x 2048 px.

  • Preferred texture size is 1024x1024 px. Use 2k textures only for large meshes that require the detail.

  • Texel Density

    • The 3rd person view game benchmark for the texel density is 512px/m. However if texture atlases with solid colours for low-poly style games is used this number can be smaller.

    • Free plugins such as Texel Density Checker are useful tools to determine and set the size of the UV map in relation to the texture image.

  • Alternatively this can be done by manually scaling the UV in relation to a known dimension to the required size.

  • Materials should have lower-case names. This is due to a Godot engine issue which may fail to reference upper-case material resources when building for Android or iOS.

  • If a material assigned in Blender matches an existing material name in Godot, i.e. wood (in Blender) the .escn exporter will automatically assign wood.tres to the imported mesh. Once setup this significantly speeds up the import/export pipeline especially if modules aneed to be updated.

  • If using the .gltf pipeline the material/texture file location must be set during export.

Colliders

  • By adding the suffix -col to either the object- or mesh data-block in Blender and exporting it as .glTF or .escn, Godot will automatically generate a collision mesh.

  • By adding the suffix -colonly the exported mesh will only show up as a collision mesh which is useful when the collision is modelled separately to reduce the overall vertex count. See the official Godot documentation for further information.

  • Empty objects can also be used to import primitive collision shape i.e. BoxShape and SphereShape from Blender which tend to perform best in Godot.

Shadows

  • Realms may use a single directional light within Godot, which calculates realtime-shadows for the levels geometry. (Users may disable shadows in the quality-settings when in-game)

  • Since calculating shadows can be an expensive process, disabling that calculation for meshes that do not need to cast shadows can result in performance gains.

  • In order to define which meshes should and should not cast shadows, add SHADOW0 or SHADOW1 anywhere in the name of a mesh. 0 indicating that the mesh is excluded from shadow calculations, 1 indicating it is included.

Size - Scale

  • The object size does not change when importing an asset from Blender to Godot. However if the original model was created in another 3D program ensure it is still correct after importing it into Blender. Press N to reveal the sidebar and select Item to display the dimension of any selected object. Rescale S if necessary.

  • Before exporting ensure to select the mesh and Object -> Apply -> All Transforms to make any changes permanent.

Join

  • Join all meshes in Blender prior to export excluding separate collision meshes by selecting the meshes and Ctrl+J which will automatically preserve assigned materials/vertex-groups etc.

  • After joining check again for duplicate vertices and correct face orientations.

.GLTF Export

  • Once the asset is ready, it should be exported using the .glTF Separate format via File > Export > glTF 2.0 (.glb/.gltf). Textures may be placed in a textures folder for consistency. This will export a .gltf file, a .bin file and the necessary textures .material.

Godot

Import

Create a new assets/SCENE_NAME/models/ directory and import the .glTF Separate (.gltf + .bin + textures) or .escn exported from Blender into that location.

The import settings of the .gltf file should be set to the following if not already set to them by default:

  • Materials -> Storage -> Files (.material) (This is important in order for Godot to actually reference the imported texture files)

Open the imported .gltf, select New Inherited, then save as new scene as ASSET_NAME.tscn in assets/SCENE_NAME/scenes/.

The .tscn can now be dragged and dropped into the node tree of your SCENE_NAME.tscn under the Static Meshes node. Continue adding assets or duplicate existing assets to populate your realm.

Last updated