I did not find a question on these lines yet, correct me if I'm wrong.

Trees (and fauna in general) are common in games. Due to their nature, they are a good candidate for procedural generation.

There's SpeedTree, of course, if you can afford it; as far as I can tell, it doesn't provide the possibility of generating your tree meshes at runtime. Then there's SnappyTree, an online webgl based tree generator based on the proctree.js which is some ~500 lines of javascript.

One could use either of above (or some other tree generator I haven't stumbled upon) to create a few dozen tree meshes beforehand - or model them from scratch in a 3d modeller - and then randomly mirror/scale them for a few more variants..

But I'd rather have a free, linkable tree mesh generator.

Possible solutions:

  • Port proctree.js to c++ and deal with the open source license (doesn't seem to be gpl, so could be doable; the author may also be willing to co-operate to make the license even more free).
  • Roll my own based on L-systems.
  • Don't bother, just use offline generated trees.
  • Use some other method I haven't found yet.

Update 2015: ended up porting proctree.js to c++ https://github.com/jarikomppa/proctree

  • 5
    \$\begingroup\$ For rolling your own, I'd recommend the book 'the algorithmic beauty of plants' by Prusinkiewicz and Lindenmeyer, which is available at algorithmicbotany.org/papers/#abop. The book and the site also list a lot of research papers on the generation of virtual botany. \$\endgroup\$
    – Exilyth
    Dec 15 '12 at 1:11
  • \$\begingroup\$ I have created an online tool called 3DFlora with WebGL. It has more than 80 parameters and let you download the results as an obj file. You can create almost any kind of plants with it. Checkit it out here: 3dflora.sina-s.com \$\endgroup\$ Jul 24 '14 at 21:50

I've done a fair bit of work in this area, although most of my demos are older:

(flash 2010)
http://genesisbbs.com/appstem.html (click and drag mouse)
(directX 2006)

I highly encourage you to roll your own, if you are doing this for fun. You will almost certainly need to work with Quaternions. Understanding them is very hard, but you don't need to go too deep to use them. Think of a quaternion as a vector with an extra component: rotation. If you want your plants to twist and turn as they grow, they will need quaternions.

Other things to learn:
Lichtenberg Figures
Laplacian Growth
Voronoi Diagrams
Nearest Neighbor algorithms (google them)

I (personally) would discourage the use of L-Systems, other than to perhaps dictate a grammar for what grows where, i.e. [seed -> [root] / [trunk->branch->[flower/leaf]]. L systems are not good for responding to environmental stimuli like sunlight direction, gravity, obstacles, etc.

As for speed concerns, a single tree can be generated in realtime. For memory purposes and performance though, you will likely only want to generate a small set of trees and instance them a bit if you are dealing with forests.

Most existing tree generators are not that great (IMHO), besides the high-end ones used for Maya and such.

I also highly, highly recommend using voxels to generate the tree (then skin with a mesh if needed). The advantage of voxels is that you can easily simulate growth algorithms using things like Laplacian growth and various automata (not Conway's game of life, but other rules produce interesting results).


Personally I would probably start with pre-generated trees and only once I'd have a kick-ass forest rendering engine - complete with bushes, grass, mushrooms and stuff - would I start looking if I need more variable tree meshes.

That being said, you could take a look at ngPlant. It includes a GPL procedural tree modeler app, but the libraries that do all the heavy lifting are BSD licensed. It's written in C++.

For the forest rendering, there is (MIT licensed) Paged Geometry for Ogre rendering engine.


The main problem with procedural trees is not generating them, but rendering them all every frame at runtime. This is the reason you will see many identical trees in AAA games, it's not that they couldn't implement or write tech that created unique trees, it's that it would mean you'd have to cut out a load of other features for the game to run.

If you have many identical trees, you can rotate them and possibly scale them uniformly to make them look different from every angle, and since they are identical you can instance them in order to save precious milliseconds each frame.

Just thinking about this problem for a second, there might be a happy medium - how about you generate a few different tree parts, trunks, branches, leaves etc.. but ones that all fit together in modular ways, like tree lego. Then you could have many combinations and so some quite unique trees, but you could also instance all of the many parts for a faster running game.

  • \$\begingroup\$ Apart from the piecewise idea this answer doesn't really add anything new. \$\endgroup\$ Dec 20 '12 at 12:39
  • 3
    \$\begingroup\$ always nice when the OP is so appreciative. For a QandA site your post has a distinct lack of questions. Besides this answer directly addresses your bullet points. \$\endgroup\$ Dec 20 '12 at 18:43
  • \$\begingroup\$ Yeah, been there myself, apologies. \$\endgroup\$ Dec 21 '12 at 17:01

This is a neat little solution, and I have used it in a project and can tell you it is fast enough to gen trees on the fly why the game is running. It's certainly not detailed, but if you got rid of the billboards it could be pretty neat.


  • \$\begingroup\$ Seems like a good solution for XNA users. \$\endgroup\$ Dec 22 '12 at 9:49

I stumbled across tree[d] some time ago... I used it for only a small amount of time to test a project but that was only because I stopped development - the tool gives you a wide range of generator options to play with and, from what I remember, is quite fast. A link is below.

The downside is that it isn't a tree generator that you can incorporate. You'd have to pre-generate a few trees and then modify the data when placing them at run-time to tweak their uniqueness.

Best of all TreeD is free to use, and you can include the trees you make in your own projects, commercial or free, as long as they are not model packs, texture packs, 3D model generators, or texture generators.

  • \$\begingroup\$ Nice to see other free generators, even if it's in a library format. \$\endgroup\$ Dec 22 '12 at 9:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.