Skip to main content

Module mtl

Module mtl 

Source
Expand description

Wavefront MTL (material library) ASCII parser + serialiser.

The grammar mirrors OBJ’s: line-oriented, whitespace-separated, # introduces a comment to end of line. Each newmtl <name> opens a fresh material; subsequent lines populate the material’s parameters until the next newmtl or end of file.

This crate maps the Phong-Blinn vocabulary onto the glTF metallic-roughness model in Material, preserving the original field values in Material::extras so a re-serialise reproduces the input. The Wavefront-PBR extension (Pr, Pm, Pc, Ps, map_Pr, map_Pm) lands directly in the corresponding PBR slots.

Functions§

merge_materials_into_scene
Hoist pending texture URIs into the supplied scene as Textures and bind the result on each material via TextureRef. Materials are also added to the scene; returns the MaterialId for each input material in declaration order.
parse_mtl
Parse an MTL document.
parse_mtl_with_scene
One-shot parse + scene-hoist for direct MTL-decoder callers.
serialize_mtl
Serialise a slice of materials to MTL format.