Skip to main content

glTF Files

This section provides additional information on the use of glTF files in Scene Composer.


Animations

Scene Composer provides a working sample that shows how to use glTF animations. See Physically Based Rendering Solution for details.

Scene Composer supports interpolation animation; however, morphing or the channel path "weights" are not supported.

The following animation types are supported:

  • translation
  • rotation
  • scale.

The following interpolation strategies are supported:

  • linear
  • step
  • cubicspline

glTF specifies rotation angles in quaternions. CGIStudio converts the values to Euler angles.

For more information about animations, see the Khronos website: animations. For a more detailed description about interpolation types see the Khronos website: animation sampler.



The Software Development Kit (SDK) version

The glTF importer uses the Microsoft glTF-SDK in version v1.9.1.0. Download the Microsoft glTF-SDK from Microsoft gtTF-SDK GitHub repository.



Reference models

Scene Composer uses the boombox as a reference model. The folder cgi_studio_content/3D/glTF/ contains the glTF file. Visit The Khronos website: glTF Sample Models to find more available reference models.

drawing-4-1676342296.png


Supported glTF Extensions and Multi UV

Scene Composer’s glTF import supports the following glTF 2.0 extensions as well as multiple UV sets (Multi UV).

Extension Description
KHR_lights_punctual Imports point, spot, and directional lights defined in the glTF file as lights in Scene Composer.
KHR_materials_anisotropy Reproduce materials with anisotropic highlights, such as brushed metal.
KHR_materials_clearcoat Reproduces materials that have a clear-coat layer (clear paint).
KHR_materials_ior Specifies the Index of Refraction (IOR) and improves refraction for materials such as glass.
KHR_materials_iridescence Represents iridescence effects where the color changes depending on the viewing and incident angles.

KHR_materials_specular

Supports materials that independently control the intensity and color of specular reflection.
KHR_materials_unlit

Supports “unlit” materials that are not affected by lighting calculations.

 

KHR_texture_transform

Interprets UV transforms such as offset, scale, and rotation per texture.

 

KHR_materials_emissive_strength

This extension scales the emissive color or texture by a scalar emissiveStrength factor, allowing materials to represent much brighter emission, especially in high dynamic range (HDR) rendering environments.

 

KHR_materials_sheen

This extension adds a sheen layer on top of an existing physically based rendening (PBR) material to simulate soft, fabric-like highlights caused by fine microfibers such as cloth or velvet.

 

Even when UV sets other than uv0 are specified in these extensions, Scene Composer imports multiple UV sets (Multi UV) and assigns them to the corresponding textures.

Limitations
  • Limitations in OpenGL Embedded Systems (ES) 2.0 might prevent some sample glTF files that use these extensions from producing the expected visual results in ES 2.0 environments.

  • Some extensions, such as KHR_materials_anisotropy, KHR_materials_iridescence, KHR_materials_specular, KHR_materials_ior, KHR_materials_emissive_strength and KHR_materials_sheen cannot be used together with KHR_materials_unlit by design.

  • Meshes that use KHR_materials_anisotropy must have normal and tangent attributes, or the base material must have a normal map. If these conditions are not met, the anisotropy effect may not be rendered correctly.

For details on the properties and parameters of each extension, refer to the glTF 2.0 extension specifications provided by Khronos.


Physically Based Shading (PBS)

The importer applies the metal-roughness material model to the imported 3d model. If the glTF file does not define image-based lightning (IBL) textures, the importer applies a default material. Scene Composer provides shaders for OpenGL ES 2.0 and 3.0.

The property names used in SceneComposer differ from the glTF standard:

Standard Property Name Usage in SceneComposer
baseColor u_Base Color Factor
metallic determined by the X value in the u_Metallic Roughness Value
roughness determined by the Y value in the

The importer automatically sets the following appearance and shader properties, but you can also configure them manually:

Uniforms:
Optional Uniform Name Description

u_MetallicRoughnessValues holds the metallic factor in X and the roughness factor in Y. The shader multiplies these values with the metallic and roughness values from the metallic-roughness texture on a per-pixel basis. If no such texture exists, the shader uses the values from the uniform instead.

u_BaseColorFactor is a factor that the shader multiplies with the value from the albedo texture on a per-pixel basis. If no such texture exists, the shader uses the values from the uniform instead.

u_MipmapCount specifies the number of mipmaps, excluding level 0, from the specular/radiance texture.
optional u_NormalScale is a factor that the shader multiplies with the X and Y component of the normal. This uniform is available only if the fragment shader and vertex shader define HAS_NORMALMAP.
optional u_OcclusionStrength is a factor for the linear interpolation between the color and the color times ambient occlusion. This uniform is available only if the fragment shader and the vertex shader define HAS_OCLUSIONMAP.
optional u_EmissiveFactor is a factor that the shader multiplies with the value from the emissive texture on a per-pixel basis. This uniform is available only if the fragment shader and the vertex shader define HAS_EMISSIVEMAP

 

drawing-5-1726241135.png
 Textures:


Optional Texture Name Channels Texture Level Description
optional albedo  RGBA 0 Set at texture unit 0, and define HAS_BASECOLORMAP in the fragment shader.
optional metallic-roughness  GB 1 Set at texture unit 1, and define HAS_METALROUGHNESSMAP in the fragment shader. The metallic values must be stored in the blue channel. The roughness value must be stored in the green channel of the texture.
optional tangent-space normal RGB 2 Set at texture unit 2, and define HAS_NORMALMAP in the fragment shader and vertex shader.
optional occlusion R 3 Set at texture unit 3, and define HAS_OCCLUSIONMAP in the fragment shader and vertex shader. The occlusion values are stored in the red channel of the texture.
optional emissive RGB 4 Set at texture unit 4, and define HAS_EMISSIVEMAP in the fragment shader and the vertex shader.
optional Image-based lighting (IBL)
 

Provide the following textures for IBL to work correctly:

  • diffuse radiance cubemap (see below)
  • specular/radiance cubemap (see below)
  • bidirectional reflectance distribution function (BRDF) (see below)
optional IBL - diffuse radiance cubemap RGB 5

Set at texture unit 5, and define USE_IBL in the fragment shader.

optional IBL - specular/radiance cubemap RGB 6

Set at texture unit 6, and define USE_IBL in the fragment shader. Build the specular pre-convolved environment into the mipmaps. The importer automatically sets the number of mipmaps, excluding level 0, in the shader uniform u_MipmapCount. If you set this cubemap manually, configure this value manually.

optional IBL - bidirectional reflectance distribution function (BRDF) RG 7

Set at texture unit 7, and define USE_IBL in the fragment shader.


The Scene Tree shows details of the imported appearance:

drawing-5-1732892596.png



Mesh:
Optional Mesh Properties Description

position Provide the mandatory position attribute.
optional normals Define HAS_NORMALS in the fragment shader and vertex shader.
optional tangents Define HAS_TANGENTS in the fragment shader and vertex shader.
optional uv set Define HAS_UV in the fragment shader and vertex shader.

 

glTF_shader_variants.png

The image shows different shader variants (Click the image to enlarge it).
Uniform Setter:
Optional Uniform Setter Description
  model view projection Provide the mandatory model view projection.
  model matrix Provide the mandatory model matrix

normal model matrix Provide the normal model matrix, which is mandatory if the shader defines HAS_NORMALS and HAS_TANGENTS.

 

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 information about physically based rendering, see the Khronos website: metallic roughness.



Khronos references include the following resources:

The Khronos specification is available here:

The following viewers are available: