matcat
A compact, procedural material catalog for simulations.
Instead of maintaining giant lookup tables of materials, matcat encodes every material as a 5-byte identifier (MatCatId), then procedurally derives its physical properties. This allows trillions of possible distinct materials — far more than you could ever hand-author — while still giving deterministic, repeatable results.
Features
-
Compact IDs
MatCatIdis only 5 bytes (u8category,u16variant,u16grade).
Each ID maps deterministically to a unique material. -
Procedural properties
props_for(id)derives a completeMatPropsstruct, covering mechanical, thermal, chemical, and electromagnetic properties. -
Distance metric
Compare materials in property-space with a Euclidean distance function. -
Search
find_closest_materiallets you match a target set of properties against a search space ofMatCatIds. -
Blazing fast
Property derivation (props_for) takes ~12ns; searching 1000 candidates takes ~17µs (see benches).
Example
use ;
Use cases
- Simulation engines that need consistent materials without manual authoring.
- ECS systems where materials are components.
- Procedural generation of worlds, objects, and environments.
- Approximate matching for “what’s the closest material to this set of properties?”
Performance
Benchmarked on a modern x86 CPU:
props_for: ~12 nsfind_closest_material(1000 candidates): ~17 µs
License
MIT