Overview
Filament uses image-based lighting (IBL) for realistic environmental reflections and indirect lighting. Environment maps are typically stored as cubemaps and processed using thecmgen tool to generate the necessary data for physically-based rendering.
The cmgen Tool
cmgen is a command-line tool that processes environment maps and generates:
- Prefiltered cubemap for specular reflections
- Spherical harmonics for diffuse irradiance
- DFG lookup tables for split-sum approximation
- KTX container files for efficient loading
Basic Usage
Common Options
Advanced Options
Loading IBL in Filament
Using FilamentApp (Recommended)
Manual Loading
Spherical Harmonics
Load spherical harmonics for diffuse irradiance:Creating a Skybox
Intensity and Exposure
Adjust IBL brightness:Custom Environment Setup
From the gltf_viewer sample:Environment Map Workflow
1. Capture or Find HDR Environment
- Photograph with 360° camera
- Use HDR panoramas from HDRI Haven, Poly Haven, etc.
- Create synthetic environments in 3D software
2. Process with cmgen
3. Load in Filament
Multiple Environments
Switch between different IBL setups:Performance Considerations
- Resolution: 256x256 is good for most scenes, 512x512 for high-quality
- Format: KTX with RGB16F for HDR, RGBM for LDR compatibility
- Mipmaps: cmgen generates optimal mipmap chain for specular
- Sharing: Reuse IBL textures across multiple views/scenes
Common IBL Settings
| Scene Type | Intensity (lux) | Size | Blur |
|---|---|---|---|
| Indoor studio | 5,000 - 10,000 | 256 | 0.1 |
| Outdoor day | 20,000 - 50,000 | 256-512 | 0.05 |
| Outdoor overcast | 10,000 - 20,000 | 256 | 0.1 |
| Night scene | 500 - 2,000 | 128-256 | 0.0 |
| Product render | 15,000 - 30,000 | 512 | 0.05 |
Debugging IBL
See Also
- Textures - Cubemap texture formats
- glTF Assets - Loading environment maps from glTF