Procedural 2D Foliage Generation

Hi everyone !

Today, I present the project I am currently working on : a way to generate 2D foliage proceduraly. I want to publish it on the Asset Store once it’s complete, and as such, I open this thread to have feedback on it as I go. For starters, here are a few screenshots :

All of them are currently drawn with debug lines, but will be rendered with generated geometry in the end. It is running in real time, and can be seen growing. For now, there are only a few options :

  • The pattern of growth. Basically, you define a pattern composed of branches and buds. Buds can grow new branches when they germinate, and branches bears a terminal bud, and several intermediate buds (you define their position along the branches). Buds and branches all possess an angle of growth.

  • The germination infos. Here, you can find the starting random seed, the maximum number of generations produced, the height limit (all branches bellow this height are cut off), an angle tolerance (to randomize the default angle of the buds and branches, like, if the starting angle of the branch is defined at 20, but there is a tolerance of 5, it can range from 15 to 25), and finally the number of steps used to draw the branches (more steps means more smoothness).

  • A branch destruction factor. At each germination, there is a chance the branch does not germinate. A secondary factor is applied at each generation, so you can make it so there are more and more branches being destroyed at each generations.

  • The environmental conditions (basically, a 2D vector). This way, you can simulate wind and gravity effects. A secondary factor allow you to control this effect through the different generation (so you can make the trunk stay straight, and having the child branches more and more affected by the directionnal vector).

  • The length of the branch. At each generation, a factor (which you can define) of this length is given to the child branch. This way, the farther you go in the generation, the smaller the branches are if you want. Or on the contrary, you can make the child branches be longer than the parents.

  • The animation info. Here there is the current life of the tree, it’s growth speed, the time it takes for the branches to reach their maximum length, and the time it takes for them to spread and reach there angle of growth (they start growing straight along the parent branches, and then deploy themselves).

With only this factors, I can already generate many different foliage (looking at them growing is really time consuming, I find it so freaking cool). Here are the few things that I will try to implement next :

  • I want to work on a way to make the tree find a balance (right now, the tree can possibly grow only on the right if the left buds are destroyed early). This will go in pair with making the branches go down with the weight of the child branches.

  • Start generating the 2D geometry and apply textures to it. I will probably go with a buffer that I push to a geometry shader.

Well, that’s it for now. If you want to provide your insight on this, have an idea of a cool feature that you would want to see if you had to purchase the asset, or anything, please de not hesitate to leave a message bellow ! ^^
Thanks for your time.

Edit 06/03/2016 :

Hi !
Well, it has been a week since I opened this thread. I did some rework on the inspector and the drawing system. Now, the whole tree is computed beforehand. This way, you can set the maximum generations, and I could add a control over the random seed. I also completed my first step : drawing the branches in several steps. I updated the screenshots and the description above with new ones. :slight_smile:
Thanks again for your time.

2 Likes

Hi everyone ! I just updated my post above with new screens and a new description to match the current state of the project. Please take a look and do not hesitate to leave a comment. :slight_smile: