GlTF

From FlightGear wiki
Jump to navigation Jump to search

glTF (derivative short form of Graphics Language Transmission Format or GL Transmission Format) is a standard file format for three-dimensional scenes and models. A glTF file uses one of two possible file extensions, .gltf (JSON/ASCII) or .glb (binary). See the Wikipedia article on the subject for more information. In FlightGear glTF can be used in place of the AC3D file format to load 3D models.

glTF vs. AC3D

glTF does not deprecate the AC3D file format as both can be used interchangeably, although each one has its own advantages and disadvantages. Choosing which one to use for your project will depend on your requirements.

The main advantage of glTF is that PBR materials are handled automatically. glTF files contain PBR material information that is used by FlightGear to avoid messing with Effects manually like in the case of AC3D files. This allows 3D models to have a consistent look across all software, i.e. what you see in Blender is exactly what you will see in FlightGear. However, this advantage can also be a disadvantage. The glTF specification is quite specific about how a material is defined, so it's not possible to add custom Effects to glTF models. If your project uses custom shaders or requires special effects that cannot be handled by the standard PBR scheme (albedo/metalness/roughness), then you should be using AC3D files with custom Effects.

Unsupported Features

The glTF 2.0 specification is the best resource when it comes to glTF. All parameters and their default values are very well defined. FlightGear tries to adhere to the specification as much as possible, but there are some exceptions:

  • Embedded textures are not loaded, so all textures must be saved to external files.
  • All parameters related to animations are ignored. This includes skinning information like joints and weights, as well as the animation keyframes themselves. FlightGear provides its own system for animating objects, see Howto:Animate models.
  • Instanced geometry is not supported.
  • Cameras and punctual lights are not supported.
  • When no material has been specified for a mesh, the glTF spec suggests using a 50% emissive grey material. FlightGear uses a different default material, which is specified in fgdata/Effects/model-pbr.eff.

Usage notes for content developers

In XML you can treat glTF models the same way you treat AC3D, with a few exceptions. As described earlier, Effects can't be assigned to glTF models because they use a predefined Effect that implements the material description of the glTF specification. Material animations don't work either for the same reason. If you want to change the material parameters, you should do so in your 3D modelling software of choice (or manually editing the glTF file).

Blender

Blender glTF exporter menu location.
Example settings for exporting a glTF model in Blender.

The latest versions of Blender support glTF out of the box. You need to use a Principled BSDF to setup your materials so they can displayed correctly by FlightGear. All textures attached to this node will also be exported correctly. See the reference documentation in the Blender manual for more information about Blender and glTF.

Some important settings for the exporter include:

Format
glTF Separate (.gltf + .bin + textures) has to be selected because FlightGear does not support loading embedded assets.
Textures
Optional directory where textures will be placed. If none is selected, the textures will be in the same directory as the .gltf file.
Limit to
These parameters can be used to select which objects of your Blender scene will be exported.
Data
FlightGear does not yet support glTF cameras or punctual light sources, so you can disable eveything here.
+Y up
Make sure to keep this on. Blender uses a +Z up convention (like FlightGear), but glTF forces +Y up as the standard.
Apply Modifiers
If you have any unapplied modifiers (like a Subdivision Surface Modifier), they will applied before exporting.
UVs
Whether to export UV texture coordinates or not. You should keep this on.
Normals
Whether to export normals or not. You should keep this on as disabling them will force FlightGear to calculate them at runtime.
Tangents
Whether to export the tangent vectors or not. You should keep this off as FlightGear will calculate the tangent and binormal vectors at runtime anyway.
Vertex Colors
Whether to export the vertex colors or not. FlightGear will use the PBR information of the Principled BSDF to light the model, so vertex colors will be ignored by most Compositor pipelines. You can keep this off in most cases.
Materials
Whether to export materials or not. You should keep this on Export.
Images
Automatic will automatically choose between PNG and JPEG when saving textures. JPEG format (.jpg) will force saving as JPEG for every texture. In general JPEG provides a decent save in storage space at the cost of a negligible quality loss, so you should be using JPEG whenever possible (transparency requires PNG). Keep in mind that JPEG textures are lossy though, so you might want to keep a lossless copy for development purposes in PNG or XCF format.
Animation
Disable everything here as FlightGear completely ignores glTF animations.

Related content