Skip to main content

Import glTF Files

Supported glTF File Versions

Scene Composer supports glTF files of format version 2.0.



Select glTF File for Import

Use the Import -> glTF option from menu to open the import dialog for glTF files.

drawing-4-1676342061.pngdrawing-4-1676342061.png

The "Select File ..." button shows the Open dialog window allowing to select the glTF file.

drawing-4-1676342075.pngdrawing-4-1676342075.png

For a description of the options available, refer to Import Dialog Options. The IBL options are specific to this dialogue and allow setting the textures for radiance, irradiance and BRDF integration, you need all three of those to use IBL:

  • IBL Radiance/Specular texture contains precomputed environment convolution maps with increasing roughness stored in the mipmaps of the cubemap.
  • IBL Irradiance/Diffuse texture stores environments global lighting information.
  • IBL BRDF integration texture stores the pre-computed BRDF's response to each normal and light direction combination on varying roughness values in a 2D lookup texture.

SceneComposer supports following glTF file formats when importing:

  • glTF: This points to external binary data (geometry, key frames, skins), and images.
  • glTF-Embedded: This embeds base64-encoded binary data, and images inline using data URIs.
  • glTF-Binary: In Binary glTF, a glTF asset (JSON, .bin, and images) can be stored in a binary blob.

For more detailed information on the file formats, please see the Khronos website: GLB File Format Specification.

Import the new glTF file by pressing the "OK" button.

The experience of modifying the scene camera can be greatly improved by using the "scene camera manipulation" feature. Transformation and look-at vector might be reset after using it for navigating in the scene (you may enable it from menu File->Preferences->Editor->Enable scene camera manipulation) while the display preview window is opened (menu View->Display->Display-0).



Use of Image Based Lighting

When importing a glTF file, it is possible to select whether Image Based Lighting (IBL) should be used. This can be done by checking the corresponding checkbox in the import dialogue shown in the image above.

Note:
If IBL should be used, these three values have to be defined before importing an glTF file. After import they cannot be defined anymore. If IBL should not be used, simply uncheck the Checkbox. Then the standard is used.

The standard IBL files can be set in the Solution Options:

drawing-4-1676342150.pngdrawing-4-1676342150.png

There is also an own shared library in the references available which also contains BRDF (files for the light dissipation), Diffuse and Specular.

For the IBL Textures the following setting is recommended:

  • For the diffuse texture the MipMap filter must be set to MipMapLinear and MipMapping must be enabled

For the IBL Textures the following setting is mandatory:

  • For the BRDF texture the WrapMode must be set to ClampToEdge
  • For the BRDF texture MipMapping must be disabled

Those settings are applied if possible (if the resources are not part of a referenced shared library).



Image Based Lighting Textures

To utilize all the features of glTF's metallic-roughness materials, knowledge about its physically based rendering model is required.

Users have to provide the IBL (Image Based Lighting) textures themselves, or rely on the example textures that come with Scene Composer.

IBL textures can be created with a tool like cmftStudio or IBL Baker. They consist of a radiance cubemap with specular pre-convolved environment built into the cubemap's mipmaps, an irradiance map and a BRDF distribution map.

Keep in mind, that the default BRDF map that comes with Scene Composer is generated for white light only. If you change the light's color, the BRDF map will no longer match, thus the end result will not be correct.

The metallic-roughness parameters from glTF translate to Scene Composer's shader and Uniform Setter as follows:

"baseColorFactor" = u_BaseColorFactor
"metallicFactor" = u_MetallicRoughnessValues.x
"roughnessFactor" = u_MetallicRoughnessValues.y



Limitations

The CGI Studio glTF Importer does not support the following features:

  • Skinning
  • Morping
  • Vertex Buffer Streams
  • Sparse Accessors
  • Multiple UV Maps



Animations

There is a working sample available showing the usage of glTF animations. For this, please refer to Physically Based Rendering Solution

Interpolation animation is available, however Morphing and the channel path "weights" are not available.

Animation of:

  • translation
  • rotation
  • scale is available.

Also, the follwoing Interpolation strategies are available:

  • linear
  • step
  • cubicspline

In glTF rotation angles are specified in quaternions, for usage in CGIStudio, the values are converted to Euler-angles.

For a more detailed description on animations please refer to the Khronos website: animations. For a more detailed description on interpolation types please refer to the Khronos website: animation sampler.



SDK version

The glTF importer uses the Microsoft glTF-SDK in version v1.9.1.0. It can be downloaded from Github.



Reference models

A reference model that is being used is the boombox. The glTF file is available at the folder cgi_studio_content/3D/glTF/.

 Available reference models can be found at: The Khronos website: glTF Sample Models.

drawing-4-1676342296.png
BoomBoxModel.png
BoomBox Model



Pyhsically Based Shading (PBS)

On the imported 3d model the metal roughness material model is applied. If no IBL textures are defined a default material is applied. The shaders are provided for OpenGL ES 2.0 and 3.0.

In SceneComposer the properties are called differently from the glTF standard:

  • the standard property baseColor is called u_Base Color Factor
  • the standard property metallic is determined by the X value in the u_Metallic Roughness Values
  • the standard property roughness is determined by the Y value in the u_Metallic Roughness Values

The following properties of the appearance and shader are automatically set by the Importer, but can also be configured manually: Uniforms:

  • "u_MetallicRoughnessValues" holds the metallic factor in X, and roughness factor in Y. These values are multiplied with the metallic and roughness values from the metallic-roughness texture on a per pixel basis. If there is no such texture, the values from the uniform are used instead.
  • "u_BaseColorFactor" (RGBA) is multiplied with the value from the albedo texture on a per pixel basis. If there is no such texture, the values from the uniform are used instead.
  • "u_MipmapCount" The number of mipmaps (excluding level 0) from the specular/radiance texture.
  • (Optional) "u_NormalScale" is a factor that is multiplied with the X and Y component of the normal. This uniform is only available if HAS_NORMALMAP has been defined in the fragment and vertex shader.
  • (Optional) "u_OcclusionStrength" is a factor for the linear interpolation between the color and the color times ambient occlusion. This uniform is only available if HAS_OCCLUSIONMAP is defined in the fragment and vertex shader.
  • (Optional) "u_EmissiveFactor" (RGB) is multiplied with the value from the emissive texture on a per pixel basis. This uniform is only available if HAS_ HAS_EMISSIVEMAP is defined in the fragment and vertex shader.
    properties_import_glTF.png
    Properties panel
drawing-4-1676342353.png

 

 Textures:

  • (Optional) The albedo texture (RGBA) must be set at texture unit 0, and HAS_BASECOLORMAP must be defined in the fragment shader.
  • (Optional) The metallic-roughness texture (GB) must be set at texture unit 1, and HAS_METALROUGHNESSMAP must be defined in the fragment shader. The metallic values must be stored in blue channel. The roughness values must be stored in the green channel of the texture.
  • (Optional) The tangent-space normal (RGB) texture must be set at texture unit 2, and HAS_NORMALMAP must be defined in the fragment and vertex shader.
  • (Optional) The occlusion texture (R) must be set at texture unit 3, and HAS_OCCLUSIONMAP must be defined in the fragment and vertex shader. The occlusion values are stored in the red channel of the texture.
  • (Optional) The emissive texture (RGB) must be set at texture unit 4, and HAS_EMISSIVEMAP must be defined in the fragment and vertex shader.
  • (Optional) IBL textures. The following textures must be present for IBL to work correctly.
    • The diffuse/irradiance cubemap (RGB) must be set at texture unit 5, and USE_IBL must be defined in the fragment shader.
    • The specular/radiance cubemap (RGB) must be set at texture unit 6, and USE_IBL must be defined in the fragment shader. The specular pre-convolved environment must be built into the mipmaps. The number of mipmaps (excluding level 0) is set in the shader uniform "u_MipmapCount" automatically by the importer, or must be configured manually if this cubemap is set manually.
    • The BRDF texture (RG) must be set at texture unit 7, and USE_IBL must be defined in the fragment shader.

Details of the imported appearance are shown in the scene tree:

drawing-4-1676342384.png

 

glTF_imported_appearance.png
Image Based Lighting in Solution options

Mesh:

  • Position is mandatory.
  • (Optional) If the mesh has normals, HAS_NORMALS must be defined in the fragment and vertex shader.
  • (Optional) If the mesh has tangents, HAS_TANGENTS must be defined in the fragment and vertex shader.
  • (Optional) If the mesh as a uv set, HAS_UV must be defined in the vertex shader.
glTF_shader_variants.png

glTF_shader_variants.png

different shader variantsvariants (Click to enlarge image)

Uniform Setter:

  • Model View Projection matrix is mandatory.
  • Model matrix is mandatory.
  • Normal model matrix is mandatory if HAS_NORMALS and HAS_TANGENTS are defined in the shader.

Optimization tips:

  • Use one texture for occlusion, roughness, and metallic values, stored as an RGB texture.
  • Providing tangents in the mesh avoids calculating the tangent space matrix on a per pixel basis.

For a more detailed description on Pysically Based Rendering please refer to the Khronos website: metallic roughness.



Khronos References

Khronos Specification

Viewers