Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Procedural tree/vegetation generator

Discussion in 'Works In Progress - Archive' started by jesta, Sep 28, 2012.

  1. jesta

    jesta

    Joined:
    Jun 19, 2010
    Posts:
    293
    Hi there,

    I started working on a procedural tree/vegetation generator yesterday. It generates a vast variety of trees/plants/shrubs dynamically and most results are quite convincing. Of course it still requires a lot of tweaking.

    Here is a demo of my progress so far. Still no mesh and no lighting, but you can have fun with it I guess! Hit "n" to generate a new tree.

    http://dl.dropbox.com/u/9289442/WebPlayer.html

    Update: The project is coming along well! Here is a video showing different variations of an African acacia tree:
    [video=facebook;10151156377155753]http://www.facebook.com/video/video.php?v=10151156377155753&saved
     
    Last edited: Dec 12, 2012
  2. AMDAndrew

    AMDAndrew

    Joined:
    Aug 10, 2012
    Posts:
    90
    Cooohol :)

    I think it won't be for free ( silly me ) ?

    Keep it up, it's nice.
     
  3. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Cool, looking forward to seeing an update on this one . )
     
  4. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,550
    Great work.

    You can generate some very convincing trees with this. Procedural is the future.

    It would be cool to see this on a landscape even without bark or leaves.
     
  5. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    are these l systems?

    i lub this stuff.
     
  6. jesta

    jesta

    Joined:
    Jun 19, 2010
    Posts:
    293
    Thanks! At the moment, the trees are generated using billboards facing the camera, so I'm not sure it would look good on a landscape but I could try.

    Nope! l-systems are very complex to manage in order to give good and realistic results. I use the space colonization algorithm, which is extremely simple and versatile.
     
  7. Steve Guynup

    Steve Guynup

    Joined:
    Sep 29, 2012
    Posts:
    1
    Very cool, and close to some code I'm looking for. I'm a teacher who got roped in to doing a generative modeling project (visualizing cellular regeneration inside the eye of a Zebrafish). Its seems fun, but my students have 0 scripting skills and my own are kinda subpar...

    Hope you can post (share or sell?) the code in the next few weeks.
     
  8. jesta

    jesta

    Joined:
    Jun 19, 2010
    Posts:
    293
    Sure, if I'm able to properly convert the generated trees to a mesh, I'll be selling the package with a full api and a tree editor. If I don't have the time to do this, I could potentially release what I accomplished for free. Thanks for the comment!
     
  9. Soinklined

    Soinklined

    Joined:
    Jul 4, 2012
    Posts:
    1
    Have you explored plant succession? Because this addition would create a dynamic placement of flora while using natural systems to bring about forests (the end game). It would be rad if a developer could be painting and the longer they painted an area the farther along in succession an area would be "painted" or by erasing it would turn back time on the succession of an area.
     
  10. jesta

    jesta

    Joined:
    Jun 19, 2010
    Posts:
    293
    This would actually be quite simple to implement, I think. Thanks for the suggestion, I'll look into that.
     
  11. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,605
    I like my tree.

     
  12. jesta

    jesta

    Joined:
    Jun 19, 2010
    Posts:
    293
    Hahaha, I know it isn't perfect. This is not so hard to fix but I'm currently focusing on rendering methods.
     
  13. Caliber-Mengsk

    Caliber-Mengsk

    Joined:
    Mar 24, 2010
    Posts:
    689
    O-o am I the only one that had a fair amount of enjoyment out of building a tree, flinging it into a spin, then building another and doing the same?
     
  14. Psyco

    Psyco

    Joined:
    Oct 5, 2012
    Posts:
    5
    Ive been searching for a few weeks with no luck. How does one procedurally make a tree? i know thats a broad question, but even knowing how to access the tree.data variables would help so much. PLEASE :)

    i have been scripting a few years and am quite familiar with unity
     
  15. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,513
    Wow nice
     
  16. wamus

    wamus

    Joined:
    Sep 15, 2012
    Posts:
    24
    Keep The Project Up (That is good work dude)
     
  17. jesta

    jesta

    Joined:
    Jun 19, 2010
    Posts:
    293
    I will not provide the exact code, but the technique I used is described here: http://algorithmicbotany.org/papers/colonization.egwnp2007.large.pdf.

    It is easy to read and understand. My advice: Take the time to draw on a whiteboard or with pen and paper! It helps a lot to understand the algorithm. Good luck!

    By the way, I'm still working actively on the project. I just found a solution to polygonize the branches, so a new webplayer will be available soon.
     
  18. ZoomDomain

    ZoomDomain

    Joined:
    Aug 30, 2012
    Posts:
    150
    Brilliant... very nice trees, you could keep it just as it is , just add different modes on top if this one it's great. i would have sworn that it was 3d, because it looks like stacks of cylidners for the trunks.

    I made some abit like this using cubes instead of cylinders... Then i want to map the mesh of the cubes on on top of each other and give them a vaguely incremental UV.

    there is a briefer explanation in middle of this page:
    http://procworld.blogspot.co.uk/2011/02/space-colonization.html
     
    Last edited: Oct 6, 2012
  19. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    Unity's Tree is fine for pregenerated trees. I decided to write everything from scratch to be able to generate and modify trees in runtime in background threads.

     
  20. jesta

    jesta

    Joined:
    Jun 19, 2010
    Posts:
    293
    Very cool. I wish I had this kind of script to generate optimized geometry. Is your script (or method) available anywhere?
     
  21. Aedous

    Aedous

    Joined:
    Jun 20, 2009
    Posts:
    244
    Very cool procedural tree you have there.
     
  22. jesta

    jesta

    Joined:
    Jun 19, 2010
    Posts:
    293
    Update!

    Here is a short video showing different variations of an African acacia tree:
    [video=facebook;10151156377155753]http://www.facebook.com/video/video.php?v=10151156377155753&saved
     
    Last edited: Dec 13, 2012
  23. umauj

    umauj

    Joined:
    Nov 20, 2011
    Posts:
    80
    This looks extremely promising!
    Do you have any plans on releasing it any time soon? How much is it going to cost?
     
  24. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    SuperB_!!:!!
     
  25. jesta

    jesta

    Joined:
    Jun 19, 2010
    Posts:
    293
    I want to release it as soon as possible, but there is still work to do. Here is my to-do list:
    • Space partitioning optimization using RTrees
    • Correct some UV bugs
    • Add a ton of presets
    • Make a user-friendly tree editor
    • Create various methods to create entire forests easily from a splatmap or for a specific region

    For the price, I really have no idea. Thanks for the comments!
     
  26. Ereous

    Ereous

    Joined:
    Aug 29, 2012
    Posts:
    163
    Looks amazing.
     
  27. Gibbon

    Gibbon

    Joined:
    Sep 24, 2012
    Posts:
    1
    Afternoon all,

    I had been watching this thread with interest for a while as we planned to do a game which used procedural trees.

    Anyway we've been working on this for a couple of months, there is still a long way to go but we're quite please with the way it is going.

    Some Procedural Tree Growth

    [video=youtube_share;Qk4iNJTBCgM]http://youtu.be/Qk4iNJTBCgM

    And some manipulation of the Tree

    [video=youtube_share;PYp0ZovXCPo]http://youtu.be/PYp0ZovXCPo
     
  28. DevDuFF

    DevDuFF

    Joined:
    Jan 3, 2013
    Posts:
    17
    There is some really cool stuff in this thread. Any update on this project? I've begun working on an implementation of the space colonization algorithm, but if your project is available on the asset store I would definitely buy it, as it is very similar to what I am trying to do.