Editing glTF: Possibilities, Challenges, and Insights from UX3D
In this guest blog, Norbert Nopper, Managing Director at UX3D, discusses editing glTF models and introduces a new visual glTF editor, Gestaltor.
In this blog, I will discuss how to directly edit glTF™ models and when that may lead to higher productivity when creating 3D models. I will start with a brief introduction to glTF and common workflows that use this open standard asset file format. I will then go on to discuss the possibilities and challenges involved in directly editing glTF asset files. Finally, I will show some examples of how direct glTF editing may save you time in your production pipeline.
What is glTF?
glTF is a royalty-free file format specification from the Khronos® Group for the efficient description and transmission of 3D assets and scenes. glTF’s strength is its focus on easy processing and loading by a wide diversity of 3D engines and applications; the design of glTF makes it easily consumed by runtime software and graphics hardware.
A glTF 3D model is primarily described by a well-defined, easily parsed JSON file, which is—more or less—human-readable. glTF uses additional binary data to efficiently carry 3D geometry and textures, defined in a way that makes them easily loaded, often with no additional processing, into a GPU. For instance, glTF’s vertex data layout is defined in a way that common graphics APIs can use directly.
Authoring exchange 3D formats, such as Collada, FBX, or USD, retain a significant amount of information to retain editability and enable a designer to better understand the model they are creating. For example, DCC tools often use human-friendly Euler angles when constructing a 3D model and retain information about the order in which the angles are applied.
But when it comes to real-time delivery, glTF prioritizes ease of processing over human readability. Euler orientations from the DCC tool are converted to the more efficient quaternion format, discarding the ordering information that is not needed for displaying the model. This is what makes glTF the perfect choice as an efficient 3D delivery format, but some calculation is required to bring glTF back to a human-readable format.
glTF is a 3D asset format; it does not define how the asset is to be used. This is similar to JPEG or PNG files which can be used in an infinite number of ways, from promoting a product to storing personal memories—and those images might have been created through photography or through a paint program. The file format can be used to hold the pixels regardless of how they were generated or how they will be used.
Just like a general-purpose image file format, the 3D data inside a glTF file can also be used in many different ways, including computer games, product visualizations, visual simulations, 3D Commerce, and augmented and virtual reality applications. To meet these diverse needs, glTF is an extensible format to enable it to grow and adapt to solve new use cases.
So how is a glTF file typically created and used? A glTF file is often generated by an export operation from a DCC tool or perhaps a 3D direct scan or other tools able to generate 3D assets. Once sent to where it is needed, a glTF file is imported into your favorite runtime, such as a 3D game engine, browser viewer, or an AR application on your mobile phone.
glTF Editing Possibilities
So, as glTF is a format intended for run-time transmission and loading, why should someone directly edit a glTF file?
As we will see, directly editing a glTF can be extremely convenient, as it can save you time and streamline how you export and import 3D assets – let’s see how that might work.
As already mentioned, glTF is a combination of a JSON and a binary file. Even a GLB file is “just” a packed JSON and binary file. Because of the nature of JSON and glTF, it is easy to manipulate glTF in a text editor. For instance, node translation or material parameters are exposed in such a way that values can be changed directly.
After working with glTF files for a while, you can get used to opening a glTF file and making simple changes: setting a base color factor to a specific value or fixing a translation value, for example. This can be a lot faster than loading up the source asset in the authoring tool, making the edits, and exporting the asset again, which can be a time-consuming process.
In some workflows, the original 3D asset may no longer be available. While you can import the glTF file into a DCC tool like Blender, editing the 3D asset directly can be much faster than re-importing the asset, making the changes in the authoring tool, and then exporting it again.
Text-based editing of glTF models is very convenient, as it can be done with any text editor; but as the edits become more complex, a deeper knowledge of glTF may be required. Also, with a text editor, you are ‘editing in the fog’ with no immediate visual feedback, requiring you to validate and display the file to check that your edits have produced the desired result.
Visual Studio Code, a tool from Microsoft, is a text editor that can be used to directly edit glTF. There is a glTF plugin for Visual Studio Code, which provides an outline of the file internals to help navigate the glTF asset. Moreover, this plugin renders the current content in a web viewer of choice to provide immediate visual feedback and provides features to validate the edited glTF.
Compared to a simple text editor, such an enhanced editor provides improved productivity through asset navigation, instant visual feedback and annotation of erroneous JSON. However, this editor still requires a significant knowledge of glTF and one can produce an invalid glTF by accident.
UX3D has released a glTF visual editor called Gestaltor, with the goal of enabling designers to easily access and edit glTF models with the power similar to other 3D authoring tools.
What makes Gestaltor Different?
General-purpose DCC tools such as Blender provide much broader functionality than processing glTF. Such tools map the glTF file contents to their own internal data structures, which can cause long import and export times and result in a mapping which is not always exact. Additionally, information held in unknown extensions or extra information inside the glTF file may be lost. Consequently, editing a glTF model in a general-purpose tool may need several iterations before finding a way to export an asset accurately into glTF.
In contrast, Gestaltor is focused on directly manipulating glTF and nothing else than glTF; it cannot process more or less than what glTF can represent. This enables very fast glTF load and save times, and a designer can make edits using Gestaltor, knowing that it is not possible to create models which cannot be directly represented by the glTF format.
Additionally, compared to normal import- and export-based workflows, Gestaltor ensures that any extra information and extensions in the glTF file are preserved after saving.
A typical use for Gestaltor is to view and inspect a glTF model and to understand how a specific material effect is generated, leveraging Gestaltor’s asset navigation and immediate visual edit feedback.
glTF editing can be sorted into three categories, getting progressively more complex:
- Change existing values, e.g., change a node’s translation
- Add new properties, e.g., add a clear coat effect to an existing material
- Compose a new scene, e.g., merge two glTF into one file
Even for very skilled designers, more complex edits, such as merging two or more glTF files, become almost impost impossible with a text editor; a visual glTF editor will significantly ease the editing process.
Additionally, some edits, such as adding a clear-coat PBR effect, are much easier to tune and refine with immediate visual feedback.
For some designers, using traditional DCC tools to make needed edits to glTF files can work well. However, for those maintaining a library of 3D glTF assets, or if your workflow starts with a glTF file, then natively editing glTF files can save you time and frustration by avoiding multiple import and export loops to achieve a desired effect that fits precisely into the glTF format.