filamesh converts mesh files into Filament’s optimized binary format for fast loading and rendering.
Usage
Supported Input Formats
Any mesh format supported by Assimp, including:- FBX
- OBJ
- GLTF/GLB
- And many others
Requirements
Input meshes must have at least one set of UV coordinates (texture coordinates).
Options
--help, -h- Print help message--license- Print copyright and license information--interleaved, -i- Interleave mesh attributes- Stores vertex data in an interleaved format for better cache coherency
--compress, -c- Enable compression- Uses meshoptimizer compression for smaller file sizes
--ignore-uv1, -g- Ignore the second set of UV coordinates- Use when secondary UVs are present but not needed
Output Format
The.filamesh binary format contains:
Vertex Attributes
- Positions:
half4(XYZ + W=1.0) - Tangents:
short4quaternion (encodes tangent, bitangent, and normal) - Colors:
ubyte4(RGBA, 0-255) - UV0:
half2orshort2(primary texture coordinates) - UV1:
half2orshort2(optional secondary texture coordinates)
Storage Modes
Non-Interleaved (default)
Attributes stored in separate arrays:Interleaved (with -i flag)
Attributes stored per-vertex:
UV1 attribute cannot be used in interleaved mode.
Mesh Parts
Each mesh can have multiple parts (sub-meshes), with each part:- Using a contiguous range of indices
- Having its own material ID
- Including a bounding box (AABB)
Examples
Basic conversion
Interleaved with compression
Ignore secondary UVs
Compressed output
File Format Details
Header Structure
Flags
- Bit 0: Vertex attributes are interleaved
- Bit 1: UVs are 16-bit signed normalized integers (snorm16) instead of half-floats
- Bit 2: Vertex and index data are compressed using meshoptimizer
Part Structure
Materials
Processing Pipeline
filamesh automatically:
- Triangulates all geometry
- Generates smooth normals if not present
- Calculates tangent space for normal mapping
- Optimizes topology:
- Joins identical vertices
- Optimizes mesh order
- Improves cache locality
- Pre-transforms vertices (bakes transformations)
- Encodes tangent frames as quaternions
- Converts UV coordinates to half-float or snorm16
- Computes bounding boxes for culling
UV Coordinate Encoding
filamesh automatically chooses the best UV encoding:
-
Half-float (
half2): Used when UVs are outside [-1, 1] range- Higher precision, larger file size
- Suitable for atlases or tiled textures
-
Signed normalized 16-bit (
short2): Used when UVs are within [-1, 1]- Lower precision, smaller file size
- Suitable for standard 0-1 UV mapping
Loading in Filament
See the README for complete loading examples. Basic loading pattern:Best Practices
- Use compression (
-c) for production to reduce file size - Use interleaved (
-i) for better cache performance (if not using UV1) - Validate UVs - Ensure your source mesh has proper UV unwrapping
- Material names - Use meaningful material names in source files
- Triangulate - While filamesh does this automatically, pre-triangulating in your DCC tool gives you more control
Troubleshooting
”mesh does not have texture coordinates”
Ensure your 3D model has UV coordinates. In Blender/Maya/Max, check that the model is properly UV unwrapped.”mismatch in # of verts and # of secondary texcoords”
Either fix the secondary UVs in your source file, or use--ignore-uv1 to skip them.