Skip to content

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 ​

ParameterDescription
target_objectsModel-name prefixes, or a MaterialTarget for exact prepared object names.
contextOptional compatibility argument that prepares resources immediately. New code lets Randomizer.prepare(scene) do this.
typesPBR 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.
materialsMaterial 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.
seedOptional private integer seed for this node.

Modes control assignment scope:

  • active changes the active material slot of each selected mesh.
  • object samples one material and applies it to every slot of that object.
  • slots samples each slot independently. Use material_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.

Next Steps ​