Skip to content

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 ​

PortTypeDirectionDescription
index_inscalarinputDrives Index from a wire.
A, B, C…anyinputThe options. The node takes the type of the first wire you connect to an option.
outsame as the optionsoutputThe picked option, unchanged.

Parameters ​

ParamTypeDefaultDescription
indexscalar0Which 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.
  • Loop In — per-pass choices
  • Mix — blends two images rather than choosing one