Working with GLTF Files
A GLB file is a compact, binary version of glTF. GLB files combine models, animations, and physically based rendering (PBR) textures into a single, efficient file. This format is popular in web applications, gaming, and machine learning because of the following advantages:
- It’s lightweight and loads quickly in browsers and on mobile devices.
- Its structure supports PBR, giving models a realistic look in interactive applications.
- As a compressed glTF format, it’s efficient for managing and displaying 3D data in AI and training workflows.
GLB files are versatile and ideal for projects needing realistic 3D models that are quick to load and suitable for real-time environments.
Importing and Exporting GLTF Files
To import a GLTF file into SketchUp, follow these steps:
- Select File > Import.
- Locate and select the .glb file you want to import.
- (Optional) Click Options. By default Preserve Drawing Origin is selected. This option imports your file using the origin in the original file. You can choose not to preserve the drawing origin when importing. Click OK to proceed.
- Click Import.
To export a model as a GLTF file, follow these steps:
- Select File > Export > 3D Model.
- Navigate to the location where you want to save your file.
- From the drop-down list, select GLTF Binary File (*.glb).
- Change the name of your file if necessary and click Export.
Importing and Exporting Materials as GLB FIles
To import materials, you will use SketchUp’s reader. SketchUp’s reader helps determine the diffuse color based on the material type when importing a material. If the material is textured, the diffuse color is set to pure white. Otherwise, it uses the specified diffuse color.
SketchUp calculates the ambient and specular colors by multiplying the diffuse color by a factor of 0.5. The emission color is always set to black. The reader extracts appropriate metalness, roughness, ambient occlusion values and maps for materials using physically based rendering (PBR).
For GLB files, the reader processes a material as follows:
- Reads emission, normal, and occlusion maps and their associated factors.
- If a specular-glossiness map is present, the diffuse color and map are filled using the diffuse factor (with the fourth channel representing alpha).
- The reflection color is derived from the specular factor, and the roughness is calculated as (1 – glossiness).
- If a specular-glossiness map exists, its channels are extracted. The first, second, and third channels are combined to form the reflection map, while the fourth channel is inverted to serve as the roughness map.
- If a metallic-roughness map is available, the reader overrides the diffuse color and map with the base color and map.
- From the metallic-roughness map, channels are extracted to set the occlusion map (if not previously set). The second channel is used for roughness, and the third channel for metalness.
SketchUp’s writer uses the alpha mode determined based on the alpha value. If alpha equals 1, the mode is set to Mask. The writer saves the following material properties:
- The writer supports PNG, JPG, JPEG, and JPE formats. In cases where other formats are provided, the writer attempts to convert them to PNG.
- Emission, occlusion, and normal maps are exported as part of the general GLTF material. If no normal map is provided, it will be replaced by the bump map.
- Exported files include two material objects:
- Specular/Glossiness: This material includes the diffuse factor and diffuse map, with the specular factor derived from the reflection color and the glossiness factor calculated as (1 – roughness). Reflection maps are split into three separate maps, named in the format
separated_{texture_name}_{channel_number}.{format}
. These separated maps, along with the inverted roughness map, are combined to generate theSpecularGlossinessTexture
. - Metallic/Roughness: This material includes the base color and base map from the diffuse. The Ambient Occlusion (if not already set), Roughness, and Metalness maps are combined into a single map, named as
Combined_{texture_name}.{format}
. This combined map is referred to as theMetallicRoughnessTexture
.
- Specular/Glossiness: This material includes the diffuse factor and diffuse map, with the specular factor derived from the reflection color and the glossiness factor calculated as (1 – roughness). Reflection maps are split into three separate maps, named in the format