Overview
Filament’sTexture class supports 2D textures, 3D textures, cube maps, and automatic mipmap generation. Textures can be created with various internal formats and compression types.
Creating Textures
Basic 2D Texture
Cube Map Texture
3D Texture
Texture Formats
Common Internal Formats
| Format | Description | Use Case |
|---|---|---|
RGBA8 | 8-bit RGBA | Standard color textures |
RGB8 | 8-bit RGB | Color without alpha |
R8 | 8-bit single channel | Masks, grayscale |
RGBA16F | 16-bit float RGBA | HDR color |
RGB16F | 16-bit float RGB | HDR without alpha |
R16F | 16-bit float single | HDR grayscale |
DEPTH24 | 24-bit depth | Depth buffers |
SRGB8_A8 | sRGB 8-bit RGBA | sRGB color textures |
Compressed Formats
| Format | Description | Platform |
|---|---|---|
EAC_R11 | 11-bit single channel | Mobile (OpenGL ES) |
EAC_RG11 | 11-bit two channel | Mobile (OpenGL ES) |
ETC2_RGB8 | RGB 8-bit compressed | Mobile (OpenGL ES) |
ETC2_SRGB8_A8 | sRGB+Alpha compressed | Mobile (OpenGL ES) |
DXT1_RGB | BC1 RGB compression | Desktop |
DXT5_RGBA | BC3 RGBA compression | Desktop |
RGBA_ASTC_4x4 | ASTC 4x4 block | Modern GPUs |
Uploading Texture Data
Single Level Upload
Multiple Mipmap Levels
Cube Map Upload
Automatic Mipmap Generation
Filament can generate mipmaps automatically:generateMipmaps():
- Format must be color-renderable
- Usage must include
SAMPLEABLEandCOLOR_ATTACHMENT - Cannot be used with 3D textures
Texture Providers (glTF)
When loading glTF assets, texture providers decode image data:STB Provider
Handles PNG and JPEG formats:KTX2 Provider
Handles Basis Universal compressed textures:WebP Provider
Handles WebP format (if supported):Texture Swizzling
Remap texture channels:External Textures
For platform-specific image sources (video, camera):Asynchronous Operations
For non-blocking texture creation and upload:Best Practices
- Use compressed formats on mobile for better performance
- Generate mipmaps for textures that will be minified
- Use appropriate precision: RGBA8 for LDR, RGBA16F for HDR
- Check format support before using platform-specific formats
- Power-of-two dimensions for better compatibility (not required)
- Release pixel buffers after upload to free memory
See Also
- glTF Assets - Loading textures from glTF files
- Environments - Environment map textures