matc) is a command-line tool that compiles material definitions (.mat files) into material packages that can be loaded by Filament at runtime.
Overview
Material definitions are human-readable text files that describe materials. Thematc compiler processes these definitions and generates optimized binary packages containing:
- Compiled shader variants for different platforms
- Material metadata and parameters
- Optimized shader code for Metal, Vulkan, OpenGL, and other backends
Installation
Thematc tool is included in the Filament SDK. After building Filament or downloading a release:
Basic Usage
Compile a material definition:output.filamat, a material package that can be loaded by Filament.
Command-Line Options
Input/Output
Platform Targeting
By default,matc generates shaders for all supported platforms. You can target specific platforms:
mobile- Android (OpenGL ES, Vulkan) and iOS (Metal)desktop- Windows, macOS, Linuxall- All supported platforms (default)
Optimization Levels
Variant Filtering
Reduce package size by excluding unnecessary shader variants:directionalLighting- Directional lightsdynamicLighting- Point and spot lightsshadowReceiver- Shadow receivingskinning- Skeletal animationssr- Screen-space reflectionsstereo- Stereoscopic renderingfog- Fog effectsvsm- Variance shadow maps
Debug Options
Material Source Embedding
Common Workflows
Development Build
During development, use faster compilation with debug info:Production Build
For production, optimize and strip unused variants:Mobile-Only Build
Optimize for mobile platforms:Material Packages
Loading Materials
Load compiled material packages in your application:Material Instances
Create instances to set parameter values:Specialization Constants
You can specialize constant parameters when building materials:Error Handling
Common Errors
Shader Compilation Errors:material() function.
Validation
matc performs extensive validation:
- GLSL syntax checking
- Parameter type validation
- Material property compatibility
- Shader variant generation
Build System Integration
CMake
Gradle (Android)
Makefile
Performance Tips
Reduce Compilation Time
- Use variant filtering to skip unused variants
- Target specific platforms during development
- Disable optimization for debug builds
Reduce Package Size
- Optimize for size in production
- Strip unused variants
- Target only needed platforms
Advanced Features
Multiple Material Outputs
Generate platform-specific packages:Shader Inspection
Inspect generated shaders:Troubleshooting
matc Command Not Found
Ensurematc is in your PATH or use the full path:
Compilation Failures
- Check GLSL syntax in your shader code
- Verify all parameters are properly declared
- Ensure material block is valid JSON-ish
- Use
--verbosefor detailed error messages
Runtime Loading Errors
- Verify the
.filamatfile was generated successfully - Check platform compatibility
- Ensure the package matches your Filament version
Next Steps
- Learn about material properties
- Explore PBR shading models
- See creating materials for examples