set_material
Assign Principled BSDF materials to meshes by color, texture, alpha, emission, or maps, returning glTF-compatible material settings for export.
Instructions
Give meshes a material (Principled BSDF, exports to glTF). The quick form is names and color: '#rrggbb' or
[r, g, b] in 0..1. Without material the name comes from the numbers, so equal parameters reuse one material
(fewer draw calls); an existing name is rebuilt. Slot 0 gets it: use assign_material_faces for parts of a mesh.
alpha below 1 is glTF BLEND: glass only, transparent faces cost sorting. emission is {"color": "#ffcc66",
"strength": 2.0}. coat is a clear layer. subsurface does not reach glTF.
Image paths (the meshes need a UV map: unwrap or palette_uv first): texture (base colour; color then tints
it, '#ffffff' keeps it; alpha multiplies its alpha), normal_map (tangent space), roughness_map and metallic_map
(grey), or orm_map instead of those two (R occlusion, G roughness, B metallic). A map replaces its number.
bump {"scale": 20, "strength": 0.3} is a procedural noise for renders only: bake_maps turns it into a normal map.
The answer has gltf: alphaMode, the factors and the texture slots that will be written. For patterns (wood,
bricks, worn metal) use procedural_material.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bump | No | ||
| coat | No | ||
| alpha | No | ||
| color | Yes | ||
| names | Yes | ||
| orm_map | No | ||
| texture | No | ||
| emission | No | ||
| material | No | ||
| metallic | No | ||
| roughness | No | ||
| normal_map | No | ||
| subsurface | No | ||
| metallic_map | No | ||
| roughness_map | No |