Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Tree LOD System for Unity Terrain

Discussion in 'Assets and Asset Store' started by JanDawid, Apr 20, 2017.

  1. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    ASSET STORE PAGE

    VIDEO DEMO

    Unity has a great Tree Creator included in the Editor, and these trees can be painted onto a Terrain with ease, and allow the tree to interact with Wind Zones and have randomised heights and sizes.

    There is a problem that trees can only have two levels of detail (LOD), that being the full resolution tree and a billboard of the tree (which is automatically created when being painted onto the terrain).

    So if you want more LOD groups for your trees, you need to create a separate game object with various LOD of the tree as child objects and save it as a prefab. If you decide to paint in the prefab as a tree on the terrain, the trees no longer become affect by wind, and the only other option left is to manually paint on the trees as individual game objects.

    This asset allows for the user (you) to just put a simple script onto the terrain and you're good to go! The script will let you paint on your tree LOD prefab as a regular tree through the terrain tree painter, with all the different sizes and heights you like, and at runtime it'll create the trees at the correct positions on the terrain, under the same sizes and rotations that you painted on and they will also interact with the wind! Now you can have all the LOD you like for your tree with no need for any expensive tree-creating software for this simple issue to work properly. The script will bunch each tree prototype you add to the tree painter under one parent object per tree, and it'll add it to the correct scene (assuming you're working with multiple additive scenes).

    Marvel at the low amount of setpass calls and high frame rate as you see your numerous trees.

    Note: This asset does NOT contain a way to create billboards of your existing trees. I would recommend Billboard Baker Pro.
     
    theANMATOR2b likes this.
  2. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,240
    So this adds Wind effects to LODgrouped trees painted onto the terrain....that's really the purpose of it? How does it improve frame rate? Does it generate the trees as game objects, or do they remain terrain trees?
     
  3. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    If you create LODgrouped trees and paint them onto the terrain they will not interact with the wind; basically this script just generates the trees at runtime in place of where they were painted onto the terrain while retaining all their height, width and rotation factors. And I never said it improves framerate; it's just that LODgrouped trees are more efficient than a placing full res trees everywhere and with this script you can have multiple LOD groups for the trees AND paint them onto the terrain without it losing any functionality (e.g. the wind). There's also the bonus of instantiating them in the correct scene if you're using additive scenes.

    It's nothing complex or amazing; just something that really helped me with terrain landscapes and wanting more than just 2 LOD groups per tree and wanting to use the terrain tree paint brush. Honestly there is little help out there for people that want to use Unity's built in tree creator and want more than 2 groups on their terrain, it took me days to figure out this system which is the only one that works unless you want to place them one by one, use a mesh painter asset (which I tried and didn't work very well) or stick with the limited terrain tree system Unity comes with.
     
  4. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,240
    thanks for the clarification, and that's definitely valuable, just couldn't quite figure it out from the description (and the line "Marvel at the low amount of setpass calls and high frame rate" suggests performance improvement).

    Have you compared performance of your method of instantiated trees against terrain trees (without LODs)?
     
    PrivateFox45 likes this.
  5. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    Here's a comparison (basically mass painted 1000 trees onto a new terrain, with a directional light and main camera):
    bam.png

    Obviously you might have to account for different LODgroup distances but it's safe to say that this is basically the performance difference (and yes I know the trees on the right use a different texture, long story short they use the same materials and same size textures for both tests).
     
  6. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,240
    thanks! That's very interesting. I have more like 10,000 trees, I wonder if the improvement would increase or decrease with volume. Could you guess?
     
  7. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    Well it depends really; say for every billboard tree in the default system is replaced with the half-res and billboard trees of my system, the default system probably would be more efficient BUT this means that where my system has fully 3D trees (albeit half res) the default system has an obvious spinning billboard instead.
    The performance hit the half-res trees have over billboard is proving to be very little and is definitely better blending with a billboard than what the default system offers with its spinning feature that spins into the correct rotation.
     
  8. amarillosebas

    amarillosebas

    Joined:
    Feb 28, 2013
    Posts:
    44
    How do you get the billboard game object of the tree?
     
  9. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    Billboard Baker Pro. Not the easiest thing to use, but has the best billboard maker for any 3D object that I've seen for its price.
     
  10. neksyt

    neksyt

    Joined:
    Feb 17, 2015
    Posts:
    3
    Hi!
    can you please make this work for standard meshes also?

    with kind regards,
    Chris