Switch
Switch
The Switch node gates growth flow.
It chooses between multiple input graphs based on conditions evaluated per internode.
Think of it as an if/else statement for growth recipes: if an attribute or map passes a test, the branch continues through one path; otherwise it follows another.
Concept
Why Switch?
- To build state-driven growth (buds → shoots → flowers).
- To gate branches by environmental conditions (e.g. prune above a certain height).
- To introduce variation (random or mapped switches).
- To make recipes adaptive without duplicating graphs.
Inputs
Input 0 — Graph A
When the switch evaluates to false evaluate this graph.
Input 1 — Graph B
When the switch evaluates to true evaluate this graph.
Output — Graph
The merged Apex graph to be passed down the network.
Parameters
- Conditions (
conditions
)
A multiparm list of gates. Each condition compares a chosen attribute against a constant, another attribute, or a mapping.- Attribute – which graph attribute to read (e.g.
height
,u
,age
). - Condition – the operation:
>=
,<=
,==
, etc. - Threshold / Attribute / Map – the value to compare against. Can be:
- Float – fixed number.
- Attrib – another attribute.
- Map – mapping chain.
- Attribute – which graph attribute to read (e.g.
- Snippet Condition (
graph_snippet_condition
)
Advanced mode. Write inline VEX to decide routing (e.g.f@height > 5
).
Attributes
Switch does not emit new attributes, but it consumes existing ones for gating:
- Typical:
height
,u
,generation
,age
,random
. - Any custom attributes created by Wrangle or mappings are also valid.
Workflow
- Insert a Switch node into your growth recipe.
- Connect alternative subgraphs to its extra inputs.
- Define one or more conditions.
- Each internode is tested; the first passing condition determines which branch graph it takes.
📌 No conditions matched? The internode takes the default path (the last input, if connected).
How-tos
Threshold gating
Route branches only if they exceed a certain height:
Attribute: height
Condition: >= float
Threshold: 5.0
Attribute vs Attribute
Only fork when internode width exceeds length:
Attribute A: width
Condition: >= attrib
Attribute B: internode_length
Map-driven switch
Drive conditions with a mapping chain:
Attribute: height
Condition: >= map
Map: ../map1
VEX condition
Use inline VEX for custom logic:
f@height > 5 && i@generation < 3
Applications
- Stage transitions – control when a bud turns into a flower.
- Environmental pruning – stop growth above certain heights or densities.
- Random variation – shuffle different subgraphs with a noise-based attribute.
- Hybrid recipes – combine Grow, Repeat, and Switch to create adaptive structures.