Overview
Filament’sgltfio library provides a complete pipeline for loading glTF 2.0 assets and converting them into Filament entities and components. The library handles parsing glTF/GLB files, creating geometry, materials, textures, and animations.
AssetLoader
TheAssetLoader class consumes glTF content and produces FilamentAsset objects containing all necessary Filament resources.
Basic Usage
Material Providers
gltfio uses a plugin interface for material creation:JitShaderProvider
Compiles materials at runtime using thefilamat library:
- Generates optimal shaders for each material
- Slower startup time
- Smaller shader code
UbershaderProvider
Loads precompiled ubershader materials from a.uberz archive:
- Fast startup time
- Larger, more complex shaders
- No runtime compilation
Supported glTF Extensions
Filament supports the following glTF 2.0 extensions:Material Extensions
- KHR_materials_pbrSpecularGlossiness - Specular-glossiness workflow
- KHR_materials_clearcoat - Clear coat layer for materials
- KHR_materials_transmission - Transmission/refraction effects
- KHR_materials_volume - Volumetric effects and subsurface scattering
- KHR_materials_ior - Index of refraction
- KHR_materials_specular - Specular color and strength
- KHR_materials_sheen - Sheen layer for cloth-like materials
- KHR_materials_unlit - Unlit materials
- KHR_materials_emissive_strength - Enhanced emissive control
Texture Extensions
- KHR_texture_transform - UV transformations (offset, scale, rotation)
- KHR_texture_basisu - Basis Universal compressed textures
Mesh Extensions
- KHR_mesh_quantization - Quantized vertex attributes
- KHR_draco_mesh_compression - Draco mesh compression (platform-dependent)
Other Extensions
- KHR_lights_punctual - Point, spot, and directional lights
Instancing
Create multiple instances of the same asset to share resources:Animation
Access the animator from the asset instance:Resource Loading
TheResourceLoader handles asynchronous loading of external resources:
Best Practices
-
Release source data after resource loading completes:
-
Recompute bounding boxes if needed:
- Use ubershaders for faster startup in production builds
- Share AssetLoader across multiple assets to reuse material cache
- Prefer instancing over loading the same asset multiple times
See Also
- Textures - Texture formats and configuration
- Meshes - Vertex buffer setup
- Environments - IBL and environment maps