← BACK TO NOTES
2026-09-22 |
HDK HOUDINI

Growing Trees and Cliffs in C++

There are 18 plant and cliff nodes (prefix BIO).
They cover trees, grass, shrubs, ivy, flowers, nodes that place plants, and cliffs and rocks. This article takes the parts with something distinctive about how they are made: trees, the rules for placing plants, and cliffs.

Trees: two ways to build one

The tree node BIO_Tree lets you choose how branches are produced.
One way is following a curve you draw in the viewport. You shape the trunk with Bezier handles, and along that spine the node builds the root flare, a tapering trunk and branches. The other way is placing attractor points and growing branches toward them. You set an influence radius and a radius at which branches are removed (up to 0.95 times the influence radius), and bend the branches with a light direction and gravity.

There are broadleaf and conifer types, and conifers are built in whorls (default: 12 whorls of 5 branches).

The branch junctions were the heaviest part

About 90% of a tree's cook time was the branch junctions.
That is the step that joins parent and child branches one by one with Houdini's Boolean. My target for speeding it up was 50 times, and I fell short at 2 to 4 times.

Operation Conifer before Conifer after Broadleaf before Broadleaf after
New generation 2045 ms 508 ms 333 ms 144 ms
Edit trunk radius 1510 ms 512 ms

In another measurement on a tree of about 638,000 points, edits got 6.8 to 24.1% faster and a fresh generation 9.5% faster (639.7 ms became 579.0 ms). That missed the 10 times goal, and a cache hit actually became 11.3% slower.

I also added switches to compare against the original.
The environment variable BIO_TREE_DISABLE_SPEEDUP=1 turns the optimizations off, and BIO_TREE_PROFILE=1 prints the time per stage.

Rules for placing plants

When placing plants, "where" and "how much" are separate data.
Membership in a region (biome_region_*) and growth density (biome_*) are different, so to avoid a road, for example, I set only the density to 0 and leave the region color alone.

Regions are either painted with a color map or decided automatically from elevation, temperature and humidity.
The color map reads only the nearest pixel's color, so a border between red and green never invents a yellow region.

Plants are placed in a parent-and-child hierarchy.
Sub layers are scattered around Main points, and Extra layers around Sub points. If a Main point fails its elevation or temperature test, no children are born from it.

Cliffs: mesh, distance field, noise, mesh

A cliff is made by turning a mesh into a signed distance field (SDF), adding noise, and turning it back into a mesh.
The way noise is added is selectable. With "Hybrid", coarse noise is applied to the mesh (in parallel) and fine detail goes into the SDF. Scanning every voxel of the SDF serially was about 45 times slower in a draft-quality test, so I stopped doing all of it in the SDF.

With OpenCL enabled, the cliff tries the GPU path first and falls back to the CPU.

String attributes go serial

Each grass blade gets a name like blade_0, blade_1.
The code that writes those names is not parallel. The comment in the source says why: string handles are not safely writable in parallel. Numeric attributes are written in parallel and strings and groups serially, and I use the same split for tree leaves.

Summary

The tree example shows that a speed-up attempt does not always reach its goal.
Against a goal of 50 times I got 2 to 4. Keeping that number on record, honestly, makes it easier to decide where to start next time.

Next: the nodes for buildings and stone walls.

Related articles

2026-09-17

107 Terrain Nodes, One Shape

How 107 terrain nodes (prefix TERA) stay consistent. The data they pass, three layers, a shared application-area folder, tiling, and the rules for parameters.

2026-10-01

Water and Clouds in C++

How my water and cloud nodes (prefix ELEM, seven of them) are built. A shore node that solves wave arrival time, caustics that gather light, how clouds are made, and what I decided not to build.

2026-09-13

UVs in C++: Points vs Vertices

Whether a UV lives on a point or on a vertex changes how seams behave. A tour of my UV nodes (prefix PRIME), covering Promote to points, projection, island detection and trim-sheet placement.

Comments