Switch

Switch sends growth down one of two paths depending on a condition, such as height or an attribute from your source points.

Switch is an if/else for growth. It tests a condition on each shoot as the tree grows: shoots that pass carry on through whatever is wired into the True input, and the rest through the False input. Use it to change the rules partway up a tree, such as keeping side branches off the lower trunk, or switching to a different Grow above a certain height.

Inputs and outputs

  • Graph - False takes the growth for shoots that fail the condition.
  • Graph - True takes the growth for shoots that pass.

The Graph output goes wherever a Grow's output would: into a Simulate, or into an input of a Grow or Split.

With a Grow selected, the Switch tool on the Natsura toolbar asks which input to use (Terminal, Lateral or Prune) and wires a new Switch into it. If that input already had growth wired in, the tool moves it to the Switch's Graph - False input, so it now grows only where the test fails and nothing grows where it passes. To get the recipe below, move that wire from Graph - False to Graph - True.

An input left empty grows nothing. To keep branches off the lower trunk, put a Switch between the trunk Grow's Lateral input and the branch Grow, wire the branch Grow into True, and test height: below the threshold the shoots go to the empty False input and no branches grow. Wiring a different Grow into False gives the lower trunk its own growth instead, such as small shoots.

Conditions

A condition compares an attribute on the left with a Threshold value, another attribute, or a Map on the right, using an operator (==, !=, >, >=, <, <=). A new condition tests height >= 0.5.

Attributes the tree already carries, such as height, distance_to_root, u and generation, are the common ones to test, and so are attributes you put on the Simulate's source points in Houdini. The full list, with which ones change during growth, is on the Wrangle page. age is in the menu too, but on a growing shoot it is always 0 or 1, so a Switch can't tell young shoots from old with it. To switch on the age of a whole tree, give its source point an attribute of your own, such as tree_age. To test something else, write it in a Wrangle first.

The + button adds another condition. A shoot passes only when every condition is true.

For how Switch compares with forks, Split and Kill, see Forks, Split, Switch or Kill.

Decorations fill freed internodes

Branches removed by a Switch free up internodes on the parent Grow, and decorations that fill free internodes, such as an Assembly Decoration on the trunk Grow, then place parts there. Remove the decoration from that Grow if you don't want them.

Status

In 0.7.3 every condition is tested as a threshold: choosing the expression (snippet) option on a condition has no effect.