Skip to content

BackgroundRandomizer ​

SUMMARY

Picks one registered HDRI per scene. The HDRI is both what the camera sees behind the models and the ambient light that falls on them, so changing it varies backdrop, reflections and lighting at once.

Usage ​

python
from telekinesis.illusion import config
from telekinesis.illusion.randomizer.randomizer_node import BackgroundRandomizer

environment.add(config.BackgroundConfig.discover(assets / "hdris"))   # register the pool first

randomizer.add(
    BackgroundRandomizer(config.BackgroundRandomizerConfig(groups=["indoor/industrial", "indoor/studio"])),
    "background",
)

BackgroundRandomizerConfig ​

FieldTypeDefaultDescription
groupsSequence[str] | NoneNoneBackground groups, i.e. folders relative to the discovery root: "indoor" selects every indoor HDRI, "indoor/industrial" only that sub-folder.
namesSequence[str] | NoneNoneExact background names (the file stem, e.g. "boiler_room_1k").

The candidates are the union of groups and names. With neither, every registered background is a candidate. The HDRI is drawn uniformly from the candidates.

Register before you randomize

The randomizer only selects from backgrounds added with environment.add(); it does not look for files itself. An unknown group or name, or an empty selection, raises ValueError when the generator prepares the randomizer.

No background means a magenta world

An environment has no default HDRI. Without a BackgroundRandomizer (or a texture set by hand with environment.get_background().set_background_texture(path)), the world renders bright magenta, Blender's missing-texture color. To keep a fixed backdrop, use a single group or name, e.g. BackgroundRandomizerConfig(groups=["indoor/studio"]).

The example assets ship indoor/industrial, indoor/studio and outdoor/day HDRIs. Any .hdr or .exr equirectangular map works; Poly Haven is a good source.

LightRandomizer
Vary power, color and size of the lights you registered.
Next node →