MaterialRandomizer
MaterialRandomizer samples materials for active target objects. Resources are prepared once before the sample loop.
python
from telekinesis.illusion.randomizer.randomizer_node import MaterialRandomizer
node = MaterialRandomizer(
target_objects=["part_1", "part_2"],
types=["metal"],
)Parameters
| Parameter | Description |
|---|---|
target_objects | Model-name prefixes, or a MaterialTarget for exact prepared object names. |
context | Optional compatibility argument that prepares resources immediately. New code lets Randomizer.prepare(scene) do this. |
types | PBR material-directory tags such as metal, plastic, or rubber. Cannot be combined with materials. |
mode | "active", "object", or "slots". The default preserves legacy active-slot behavior for types. |
materials | Material choices: PBR tag strings, PrincipledMaterial recipes, existing materials, or custom material sources. |
material_slots | "all", or a mapping from original slot name/index to material choices. Requires slot mode. |
seed | Optional private integer seed for this node. |
Modes control assignment scope:
activechanges the active material slot of each selected mesh.objectsamples one material and applies it to every slot of that object.slotssamples each slot independently. Usematerial_slots="all"for every slot or a mapping for selected slots.
python
randomizer.add_randomizer(
MaterialRandomizer(
["housing"],
mode="slots",
material_slots={
"Body": ["metal"],
"Seal": ["rubber"],
},
seed=17,
),
"housing_materials",
)Named slots must resolve exactly once on every selected mesh; use a zero-based index when imported slot names are duplicated. Use separate nodes for models with different slot layouts.