MaterialRandomizer
Assigns a random material to each target object.
python
from telekinesis.illusion.randomizer.randomizer_node import MaterialRandomizer
MaterialRandomizer(
target_objects, # model names to re-material
context, # the Context whose materials are loaded
types=None, # material type tags to sample from
)Parameters
| Parameter | Type | Description |
|---|---|---|
target_objects | list[str] | Names of the models whose material is randomized. |
context | Context | The context whose material manager loads the requested types. |
types | list[str] | None | Material type tags to sample from, matching sub-directories of materials/ in the asset directory, for example ["metal"]. None samples from every available type. |
The requested types are loaded into the context when the node is constructed, so materials are read from disk once rather than per scene. Use one node per material family – parts in metal, bins in plastic – rather than one node for the whole scene.
Usage
python
randomizer.add_randomizer(
randomizer_node=MaterialRandomizer(
target_objects=["part_1", "part_2"], types=["metal"], context=context
),
node_name="material_randomizer_parts",
)
randomizer.add_randomizer(
randomizer_node=MaterialRandomizer(
target_objects=["crate_2"], types=["plastic"], context=context
),
node_name="material_randomizer_crate",
)