Skip to main content

glTF Files

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


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



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.
drawing-4-1682644102.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



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

different shader variants (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