Available 3D formats
在处理 3D 资产时,Godot 有一个非常灵活且可配置的导入器。
Godot works with scenes. This means that the entire scene being worked on in your favorite 3D modeling software will be transferred as close as possible.
Godot 支持以下 3D 场景文件格式:
glTF 2.0 (recommended). Godot has support for both text (
.gltf
) and binary (.glb
) formats..blend
(Blender). This works by calling Blender to export to glTF in a transparent manner (requires Blender to be installed).DAE (COLLADA), an older format that is supported.
OBJ (Wavefront) format + their MTL material files. This is also supported, but pretty limited given the format’s limitations (no support for pivots, skeletons, animations, UV2, PBR materials, …).
FBX, supported via FBX2glTF integration. This requires installing an external program that links against the proprietary FBX SDK, so we recommend using other formats listed above (if suitable for your workflow).
Copy the scene file together with the textures and mesh data (if separate) to the project repository, then Godot will do a full import when focusing the editor window.
从 Blender 导出 glTF 2.0 文件(推荐)
从 Blender 中导出 glTF 文件的方法有三种:
作为 glTF 二进制文件(
.glb
)。作为 glTF 文本文件,内嵌二进制数据(
.gltf
文件)作为 glTF 文本文件,二进制数据和纹理独立(
.gltf
文件 +.bin
文件 + 纹理)。
glTF 二进制文件(.glb
)是三个选项中最小的。包含在 Blender 中设置的网格和纹理。当放入 Godot 中时,纹理将成为对象材质文件的一部分。
glTF 嵌入式文件(.gltf
)的功能与二进制文件相同。Godot 中没有提供额外的功能,不应使用,因为文件比较大。
There are two reasons to use glTF with the textures separate. One is to have the scene description in a text based format and the binary data in a separate binary file. This can be useful for version control if you want to review changes in a text-based format. The second is you need the texture files separate from the material file. If you don’t need either of those, glTF binary files are fine.
The glTF import process first loads the glTF file’s data into an in-memory GLTFState class. This data is then used to generate a Godot scene. When importing files at runtime, this scene can be directly added to the tree. The export process is the reverse of this, a Godot scene is converted to a GLTFState class, then the glTF file is generated from that.
When importing glTF files in the editor, there are two more steps. After generating the Godot scene, the ResourceImporterScene class is used to apply additional import settings, including settings you set through the Import dock and the Advanced Import Settings dialog. This is then saved as a Godot scene file, which is what gets used when you run/export your game.
警告
If your model contains blend shapes (also known as “shape keys” and “morph targets”), your glTF export setting Export Deformation Bones Only needs to be configured to Enabled under the Animation export configurations.
Exporting non-deforming bones anyway will lead to incorrect shading.
备注
3.2 之前版本的 Blender 导出的 glTF 文件不会包含放射光纹理。如果你的模型使用这种文字,并且你使用的是较旧版本的 Blender,则必须单独分开导入。
默认情况下,Blender 在材质上禁用背面剔除,导出材质时匹配其在 Blender 中的渲染方式。这意味着 Godot 中的材质会将其剔除模式设置为 Disabled。这会降低性能,因为背面将被渲染,即使它们不可见。要解决此问题,请在 Blender 的材质选项卡中启用 Backface Culling ,然后再次将场景导出为 glTF。
Importing .blend
files directly within Godot
备注
This functionality requires Blender 3.0 or later. For best results, we recommend using Blender 3.5 or later, as it includes many fixes to the glTF exporter.
It is strongly recommended to use an official Blender release downloaded from blender.org, as opposed to a Linux distribution package or Flatpak. This avoids any issues related to packaging, such as different library versions that can cause incompatibilities or sandboxing restrictions.
From Godot 4.0 onwards, the editor can directly import .blend
files by calling Blender‘s glTF export functionality in a transparent manner.
This allows you to iterate on your 3D scenes faster, as you can save the scene in Blender, alt-tab back to Godot then see your changes immediately. When working with version control, this is also more efficient as you no longer need to commit a copy of the exported glTF file to version control.
To use .blend
import, you must install Blender before opening the Godot editor (if opening a project that already contains .blend
files). If you keep Blender installed at its default location, Godot should be able to detect its path automatically. If this isn’t the case, configure the path to the directory containing the Blender executable in the Editor Settings (Filesystem > Import > Blender > Blender 3 Path).
If you keep .blend
files within your project folder but don’t want them to be imported by Godot, disable Filesystem > Import > Blender > Enabled in the advanced Project Settings.
The .blend
import process converts to glTF first, so it still uses Godot’s glTF import code. Therefore, the .blend
import process is the same as the glTF import process, but with an extra step at the beginning.
备注
When working in a team, keep in mind using .blend
files in your project will require all team members to have Blender installed. While Blender is a free download, this may add friction when working on the project. .blend
import is also not available on the Android and web editors, as these platforms can’t call external programs.
If this is problematic, consider using glTF scenes exported from Blender instead.
从 Blender 导出的 DAE 文件
Blender has built-in COLLADA support, but it does not work properly for the needs of game engines and shouldn’t be used as-is. However, scenes exported with the built-in Collada support may still work for simple scenes without animation.
For complex scenes or scenes that contain animations, Godot provides a Blender plugin that will correctly export COLLADA scenes for use in Godot.
Importing OBJ files in Godot
OBJ is one of the simplest 3D formats out there, so Godot should be able to import most OBJ files successfully. However, OBJ is also a very limited format: it doesn’t support skinning, animation, UV2 or PBR materials.
There are 2 ways to use OBJ meshes in Godot:
Load them directly in a MeshInstance3D node, or any other property that expects as mesh (such as GPUParticles3D). This is the default mode.
Change their import mode to OBJ as Scene in the Import dock then restart the editor. This allows you to use the same import options as glTF or Collada scenes, such as unwrapping UV2 on import (for 使用光照贴图全局照明).
备注
Blender 3.4 and later can export RGB vertex colors in OBJ files (this is a nonstandard extension of the OBJ format). Godot is able to import those vertex colors since Godot 4.0, but they will not be displayed on the material unless you enable Vertex Color > Use As Albedo on the material.
Vertex colors from OBJ meshes keep their original color space once imported (sRGB/linear), but their brightness is clamped to 1.0 (they can’t be overbright).
Importing FBX files in Godot
When opening a project containing FBX scenes, you will see a dialog asking you to configure FBX import. Click the link in the dialog to download an FBX2glTF binary, then extract the ZIP archive, place the binary anywhere you wish, then specify its path in the dialog.
If you keep .fbx
files within your project folder but don’t want them to be imported by Godot, disable Filesystem > Import > FBX > Enabled in the advanced Project Settings.
The FBX import process converts to glTF first, so it still uses Godot’s glTF import code. Therefore, the FBX import process is the same as the glTF import process, but with an extra step at the beginning.
参见
The full installation process for using FBX in Godot is described on the FBX import page of the Godot website.
© 版权所有 2014-present Juan Linietsky, Ariel Manzur and the Godot community (CC BY 3.0). Revision b1c660f7
.
Built with Sphinx using a theme provided by Read the Docs.