Procedurally Generated Trees

As the leaves fall from the trees here in the Northern Hemisphere, we are greeted with a clear view of the branches and limbs that make up the skeleton of the tree. [Nicolas McDonald] made a simple observation while looking at trees, that the sum of the cross-sectional area is conserved when a branch splits. This observation was also made by Leonardo Da Vinci (according to Pamela Taylor’s Da Vinci’s Notebooks). Inspired by the observation, [Nicolas] decided to model a tree growing for his own curiosity.

The simulation tries to approximate how trees spread nutrients. The nutrients travel from the roots to the limbs, splitting proportionally to the area. [Nicolas’] model only allows for binary splits but some plants split three ways rather than just two ways. The decision on where to split is somewhat arbitrary as [Nicolas] hasn’t found any sort of rule or method that nature uses. It ended up just being a hardcoded value that’s multiplied by an exponential decay based on the depth of the branch. The direction of the split is determined by the density of the leaves, the size of the branch, and the direction of the parent branch. To top it off, a particle cloud was attached at the end of each branch past a certain depth.

By tweaking different parameters, the model can generate different species like evergreens and bonsai-like trees. The code is hosted on GitHub and we’re impressed by how small the actual tree model code is (about 250 lines of C++). The power of making an observation and incorporating it into a project is clear here and the results are just beautiful. If you’re looking for a bit more procedurally generation in your life, check out this medieval city generator.

16 thoughts on “Procedurally Generated Trees

  1. I remember back in the mid-90s, we had some very clever foliage generators running on Silicon Graphics workstations.
    In our case, they output was used in architectural, and television production.
    The processors were a bit slower, but it was fantastic to select the type of tree, the age and other parameters, then literally watch them grow before your eyes.
    We’d do complete forests, with amazing realism! Those were the days !

    1. I remember those. I didn’t get my first SGI until the late 90s but that was one of the first things I worked with as I was working on a virtual roller coaster for some new(and as of yet un-released) VR equipment that allowed you to feel motion without visual or mechanical trickery.

  2. Simple tree generating algorithms were my first introduction to the concept of recursion, via a Personal Computer World article from April 1982 about the language Logo. I was fascinated by the idea that such a simple algorithm could produce a complex shape:

    TO TREE :LENGTH :LEVEL
    IF :LEVEL = 0 [STOP]
    FORWARD :LENGTH
    RIGHT 45
    TREE :LENGTH / 2 :LEVEL – 1
    LEFT 90
    TREE :LENGTH / 2 :LEVEL – 1
    RIGHT 45
    BACK :LENGTH
    END

    https://archive.org/details/PersonalComputerWorld1982-04/page/120/mode/2up

    The syntax for the TO parameters and IF statement in the article aren’t quite correct. I had a version of LCSI Logo for the ZX Spectrum, but the effort of loading it from tape and the sluggishness of the language unfortunately limited my enthusiasm for making the most of it.

  3. Have a look at The Grove for Blender – while not “the best”, it is impressively amazing (or amazingly impressive, depending on which direction you’re looking at it).

  4. Back in the late 80’s, Electronic Arts had a game called Starflight that, at the time, used a “revolutionary” engine to store a large play area of the galaxy with hundreds of unique solar systems containing unique planets with individual topography texture, points of interest, minerals, biomes, and artifacts… all on 2 360k 5-1/4″ floppies.

  5. A shout-out to a couple of very early pioneers in this area:
    M. Eden: “A probabilistic model for morphogenesis.”
    Symposium on Information Theory in Biology, Pergamon Press, New York 1958.

    D. Cohen: “Computer Simulation of Biological Pattern Generation.”
    Nature, Vol. 216 No. 5112, 1967

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.