Animating Growth of a Procedural Tree

Jan 18, 2012   //   by Poya   //   Tech  //  2 Comments

In a previous post I wrote about the idea for a game where you’d be able to grow a forest! I finally got around to creating a video clip of a prototype I built in Unity, for generating and animating a tree over time:

This is very very basic, but it’s a starting point. Here is how it works:

  • The tree itself is first generated procedurally. I initially wanted to make this a purely rule based L-System (fractal), but decided to allow for more flexibility in terms of setting up parameters. It’s actually quite similar to (though much simpler than) Unity’s own tree system. You define a number of hierarchical branch groups, with the trunk being the root node and subsequent groups being the next generation of child branches. Then other parameters are defined which indicate how long the branches in that group are, how thick they’ll be, how they are distributed, and so on, with some randomness thrown in.

    The main reason I didn’t use the existing tree feature in Unity is that as far as I can tell, I cannot access the individual branch meshes which is what I need for animation purposes.

  • The animation involves scaling down the whole tree to 0. Then as a function of time, the branches are scaled to their full size. Now the idea is that we start scaling from the base branch group (the trunk) and work our way up, however we don’t want to start a branch group once the previous group is finished. You can imagine it’d look rather odd if a tree grew a full trunk before it started growing any branches. Instead there is an overlap of growth time. For example, for a tree that has 3 branch groups (let’s call them trunk, branch, and twig) and grows over 15 seconds, the trunk would grow over the full 15s, the branches would start growing at 5s and grow for 10s, and the twigs would start growing at 10s and grow for 5s

It looks like Unity allows me to use its tree renderer with any custom mesh. This is great because I get the all important Level-Of-Detail feature which converts the tree to a sprite at large distances.

There are a bunch of improvements that need to be made mainly to the generation code. Besides texture and leaves, lots more parameters are required to allow for good variance in the trees. Also in terms of animation, it might be interesting to look at something more sophisticated than pure scaling. It looks alright for certain kinds of vegetation but not necessarily in all situations.

2 Comments

  • Just wanna comment on few general things, The website layout is perfect, the content material is really good : D.

  • How did you create the scaling settings for the tree sections?

Leave a comment