Switch
Picks one of its inputs by number and passes it on — and only the picked input's branch is computed.
Category: Loop Menu path: Loop > Switch
Ports
| Port | Type | Direction | Description |
|---|---|---|---|
index_in | scalar | input | Drives Index from a wire. |
| A, B, C… | any | input | The options. The node takes the type of the first wire you connect to an option. |
out | same as the options | output | The picked option, unchanged. |
Parameters
| Param | Type | Default | Description |
|---|---|---|---|
index | scalar | 0 | Which option to pass on: 0 = A, 1 = B, and so on. Rounded, and held to the first or last option when out of range. |
How It Works
Before anything is computed, the engine works out which option the Switch will pick and leaves the other branches out entirely, so an unpicked branch costs nothing. The wires into unpicked options are drawn dimmed.
That works whenever the index is known ahead of time: typed in, keyframed, or computed from numbers, shapes, points or text. When the index comes from something only the render itself can produce (a simulation, an image sample, audio), every branch is computed and the pick is made at the end. The result is the same, just without the saving.
Usage Examples
Basic: toggle between two looks
Wire two versions of an effect into A and B and keyframe Index between 0 and 1. The idle version is never rendered.
Per pass: different shapes in a For Each
Inside a For Each Point, wire Loop In's index through Math (Modulo 2) into the Switch's index: even points get option A, odd points get B.
Tips
- Use a Switch instead of Mix with a 0/1 factor when the branches are expensive: Mix renders both.
- Every option should be the same type as the first one connected.