Search Unity

Landscaper - A tool for procedural foliage placement

Discussion in 'Assets and Asset Store' started by Aegon-Games, May 1, 2015.

  1. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    I was using 5.3.3 and the Conifer and Broadleaf standard assets (presumably SpeedTrees). I've since downloaded 5.3.4 and was able to generate ~66k trees without running into the issue.

    EDIT: I'm still running into the issue with 80k+ trees
     
  2. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Man. Was thinking it was 5.4 with the new GPU Instancing.
     
  3. PeterB

    PeterB

    Joined:
    Nov 3, 2010
    Posts:
    366
    I'm using Landscaper together with Gaia. The combination is very powerful, and the workflow very comfortable. Up until now, I've used Gaia for terrain generation and terrain texturing, and Landscaper to place rocks and vegetation, then Gaia again for grass. It's been working flawlessly.

    However, when I switched things around so that Gaia also does rock and stone placement, i.e. before Landscaper runs, I ran into problems: Landscaper suddenly starts placing trees several metres in the air above previously placed rocks. It works perfectly when there's nothing on the terrain, but it doesn't avoid previously placed meshes.

    It's as if Landscaper requires a pristine (or in Gaia terms, virgin) terrain. It also places the trees as GameObjects rather than Terrain Trees, even though Terrain Tree mode is explicitly specified for the Landscaper Species.

    Am I misunderstanding something? Does Landscaper require the terrain to be completely devoid of GameObject meshes in order to run? (Unity 5.3.4p1, Mac)
     
  4. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Hey PeterB,

    Landscaper will still place gameobjects trees on colliders even with terrain trees selected. This comes in handy when using large cliffs, stones. The way to get it working is through layers. Set the terrain and also any larger gameobjects you might want trees, plants to grow on to a custom layer. Then go to the Foliage Area script and set the Place Foliage On to the custom layer you set the terrain to. Make sure Default is not selected as it tends to enable it by itself. Now the trees should only grow on the enabled custom layer.
     
    PeterB likes this.
  5. PeterB

    PeterB

    Joined:
    Nov 3, 2010
    Posts:
    366
    Ah, interesting. I get your drift, but in this case what I want is for trees not to grow on previously placed meshes with colliders, I want them to avoid them entirely. Is this possible?
     
  6. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    As long as you do not have the layer that the previously placed gameobjects are using enabled in the Foliage Area script it will ignore them.

    So if you set the terrain to a custom layer, for instance Terrain, then in the Foliage Area script set the Place Foliage On layer to only Terrain then Landscaper will only place trees on the Terrain layer which should be your terrain.
     
    PeterB likes this.
  7. PeterB

    PeterB

    Joined:
    Nov 3, 2010
    Posts:
    366
    Thank
    Thanks! Will give this a try.
     
  8. PeterB

    PeterB

    Joined:
    Nov 3, 2010
    Posts:
    366
    Unfortunately, this doesn't quite work: Landscaper will correctly avoid seeking to place things on anything else but the given layers, but it doesn't avoid placing objects at the same place occupied by objects in other layers. For instance, if foliage is assigned to be placed on the terrain in layer X, a building in layer Y might still get a tree straight through it.

    The only way to fix this that I can think of is if there were a dropdown menu to exclude layers, or if Landscaper could check a given location to be clear before placing anything there.

    Or am I misunderstanding something?
     
    Last edited: Apr 2, 2016
  9. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    No, you're right - that was an oversight on my part since I've only used Landscaper on a blank terrain.

    Working on an option to exclude specific layers. Shouldn't take long.
     
    PeterB likes this.
  10. PeterB

    PeterB

    Joined:
    Nov 3, 2010
    Posts:
    366
    That's fantastic news! Many thanks indeed. :)

    Gaia has a per-object setting named "Virgin terrain", which if checked requires the spot to be unoccupied. Were you to implement that, we'd have enormous flexibility.

    Another option I'd love to see is "Can only grow in shade".
     
  11. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Took a little longer than expected, but it's done. Let me know if there are any issues. I tried adding a "Can only grow in shade" option but it turns out it's not as easy as I thought it'd be. I might have to rework some things to make that possible.


    Version 1.2.2 (Beta)
    - Download

    - Feature FoliageArea now has an option to exclude specific layers. Excluded layers will block raycasts, preventing foliage from growing on or under objects in any of these layers
    - Bugfix Fixed an issue causing shade distance to sometimes not be taken into account
     
    Teila, hopeful and PeterB like this.
  12. PeterB

    PeterB

    Joined:
    Nov 3, 2010
    Posts:
    366
    It works perfectly – many thanks! Can't complain about the turn-around time, either... I'd give you another five stars, hadn't I already done so... ;)

    Another question: placing creepers such as vertical vines, ivy, etc, is always a pain with all tools I've used so far. Is there a way Landscaper can manage this?
     
  13. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Not with the current implementation. Things like that are going to need their own logic, though I'm not sure exactly how to handle it. I've added it to my list of things to look into for possible future versions.
     
    PeterB likes this.
  14. PeterB

    PeterB

    Joined:
    Nov 3, 2010
    Posts:
    366
    Regarding the exclusion layer: it seems I was a little hasty, there remain some issues.

    Screen Shot 2016-04-02 at 18.02.47.png

    The terrain is in the Terrain layer. The rocks are in the Default layer. The layer settings above should prevent Landscaper from putting anything on the Default layer, but it doesn't. It does however work with house meshes in the same layer. Moving the rocks to a new Rocks layer and excluding that layer makes no difference. Neither does excluding all layers except Default.

    The only difference between the rocks and the buildings is that the rock meshes overlap in many places. Is there's something I'm missing?
     
    Last edited: Apr 2, 2016
  15. DivergenceOnline

    DivergenceOnline

    Joined:
    Apr 19, 2015
    Posts:
    244
    Are you going to be able to fix the bug with trees being placed as billboards or not.
     
  16. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Hmm. I haven't been able to reproduce this issue. I'm just using Unity's Physics.Linecast() so as long as there's a collider and the GameObject is on one of the excluded layers it should work.

    Which types of colliders are your houses and rocks using? Are there anything differences between them?



    No, I'm 99% sure it's a Unity thing. Paint that many trees by hand and you'll encounter the same issue. After a lot of testing I found that you can place 65,535 tree instances before the problem arises on the 65,536th.

    Presumably, Unity is keeping track of terrain trees with an unsigned 16-bit integer ID (whose maximum value is 65535). As to why it can place more trees than this but can't properly handle LOD, I have no idea. Either way, it looks like it's a limitation of Unity's terrain - and an undocumented one at that - I wasn't able to find any official confirmation.
     
  17. DivergenceOnline

    DivergenceOnline

    Joined:
    Apr 19, 2015
    Posts:
    244
    S***.

    Well the reason that's an even bigger bummer for me is that, for whatever reason, Landscaper always creates roughly the same amount of trees no matter what scale i put the cell size. Max, or minimum it doesn't matter. At 1 generation it'll create 17,000 trees. At 2 generations it'll create 70,000 and thus break the system every time.



    Our game world is massively dense in foliage and that's why i got involved in landscaper back in the day; Placing all this stuff by hand F***ing sucks hardcore. I'd love for it to be used as a promotional piece for landscaper if i could only get the damn thing to work right.
     
  18. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    The cell size doesn't affect how many instances are generated, it's just splits the generation up into a grid so that the generation time scales more linearly with increased area instead of exponentially.

    To reduce the number of instances, you'll instead want to drop the initial seed density for each species. The idea is that you start with a somewhat sparse scattering of trees, then each generation causes the forested area to expand around the initial trees.


    EDIT: I'm working on an update that includes two new pieces of functionality:

    1. Gives you an "instance count scale" slider on the foliage area itself that allows you to increase/decrease the number of trees that will be generated without having to go into each species asset to adjust the initial seed density.

    2. Add three options for how to handle the aforementioned tree instance limit:
      • Ignore - Just keep placing trees regardless of the LOD issue
      • Limit - Stops placing tree instances when the cap is hit to avoid having any permanently billboarded trees
      • Replace with GameObject - Any terrain tree instance over the cap will instead be placed as a GameObject
     
    Last edited: Apr 5, 2016
    Baldinoboy likes this.
  19. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Well that wasn't fun. I've had to make a few changes to the core of Landscaper for the new changes to work, so this is now 1.3.0 instead of a minor version.

    Version 1.3.0 (Beta)
    - Download

    - Feature FoliageArea now has an option to exclude specific layers. Excluded layers will block raycasts, preventing foliage from growing on or under objects in any of these layers
    - Bugfix Fixed an issue causing shade distance to sometimes not be taken into account

    * NEW *
    - Feature Added options for handling Unity's cap of 65,535 correctly-LODed terrain trees per-terrain
    - Feature Added a slider to control global density scale from the FoliageArea component
    - Change Added a progress bar for generation inside the editor (NOTE: Editor simulation currently can't run in the background any more)
     
    PeterB and Baldinoboy like this.
  20. PeterB

    PeterB

    Joined:
    Nov 3, 2010
    Posts:
    366
    I think I've found the root cause. The rocks have LOD versions. Landscaper assigns all placed objects to the Ignore Raycast layer during generation, but it doesn't assign them fully back to the final layer when done: only the top GameObject is assigned correctly; any children remain in the Ignore Raycast layer.

    The houses also have LOD versions, but as these have been placed manually before Landscaper does its work, they remain in the correct layer.

    Should be an easy fix.
     
    hopeful likes this.
  21. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Awesome, thanks! I've incorporated the fix into 1.3.0

    Version 1.3.0 (Beta) - Download
    - Feature FoliageArea now has an option to exclude specific layers. Excluded layers will block raycasts, preventing foliage from growing on or under objects in any of these layers
    - Bugfix Fixed an issue causing shade distance to sometimes not be taken into account
    - Feature Added options for handling Unity's cap of 65,535 correctly-LODed terrain trees per-terrain
    - Feature Added a slider to control global density scale from the FoliageArea component
    - Change Added a progress bar for generation inside the editor (NOTE: Editor simulation currently can't run in the background any more)

    * NEW *
    - Bugfix Runtime-placed terrain trees should now properly have their colliders applied
    - Bugfix Children of GameObjects placed by Landscaper should now have their layer set properly
     
    PeterB likes this.
  22. King-Hayve

    King-Hayve

    Joined:
    Aug 28, 2015
    Posts:
    7
    Hi, I am having trouble using the terrain texture mask inside my FoliageSpecies, no matter what I put in the terrain texture mask the foliage will not grow anywhere, if I remove it then it will grow everywhere. Could you post a tutorial on how to use this feature?
     
  23. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    You should just have to click the "+" button and select a texture matching one you're using on the terrain. Landscaper should then only place that species on any of the textures listed under "Terrain Texture Masks". Note that it only works on Unity terrain, not on meshes.

    Which version of Unity are you using? I've just tested with 5.1.2 and 5.4 and it seems to be working.
     
  24. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Hey @AegonGames ,

    When using the newest version I was having a problem where the trees were not rotated when placed. They are LOD trees on the terrain system. Have not too much testing into it though but figured I would mention it if anyone has had this. I am updating to 5.4 now so will test it out some more.
     
  25. King-Hayve

    King-Hayve

    Joined:
    Aug 28, 2015
    Posts:
    7
    Thanks your the quick reply!

    I am using Unity 5.3.5f1 at the moment.

    In my Unity terrain I made a terrain texture and selected the "Assets/Textures/grass.jpg" in the "Diffuse (RGB)" like so:



    Then I imported a splatmap so that the grass texture only covers where I want trees to grow and I go into my Foliage Species and I select "Assets/Textures/grass.jpg" inside the Terrain Texture Masks like so:



    This is correct right? Well this is what I get when I simulate like this:



    I get nothing, and this is what I get when I take out the grass texture in the FoliageSpecies: (to show that landscaper is placing trees successfully otherwise)

     
    Last edited: Jul 30, 2016
  26. King-Hayve

    King-Hayve

    Joined:
    Aug 28, 2015
    Posts:
    7
    I figured it out, when I created my splatmap I had the red channel covering the whole area and the green channel covering only where I wanted trees, so the grass texture was only showing through 50%. I fixed it so my red channel doesn't overlap with the green channel and it works now. Thanks for creating such a great tool!

     
  27. King-Hayve

    King-Hayve

    Joined:
    Aug 28, 2015
    Posts:
    7
    I just wanted to say thanks again, for creating such a powerful and versatile tool! I have my 24km x 24km terrain fitted out with about 600,000 trees and the game runs at 100 - 200 fps, I am very happy!

     
    hopeful likes this.
  28. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    I'm glad you got it sorted :)


    Sorry, looks like I screwed up the preprocessor directives. The rotation works, but only if you're using Unity 5.0

    In FoliageVolume.cs at about line 506 you should see this:

    Code (CSharp):
    1. #if UNITY_5_0
    What it should actually be is this:

    Code (CSharp):
    1. #if UNITY_5
     
    Last edited: Aug 2, 2016
    Baldinoboy likes this.
  29. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    That did it. Thanks!
     
  30. radimoto

    radimoto

    Joined:
    Aug 23, 2012
    Posts:
    257
    I just picked this up in the 24 hour sale. It is very straightforward to use with great results :)

    Noticed that I need to commit the above fix for Terrain Trees to rotate properly - thanks all good!
     
    Last edited: Jan 2, 2017
  31. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Oops, I thought I'd already submitted that change to the Asset Store. Sorry about that :)
     
  32. se

    se

    Joined:
    May 20, 2013
    Posts:
    46
    Is there a bug in FoliageSpecies.GetRandomArchetype() where it should just be randomStream.Next(0, Archetypes.Count) since the max value is exclusive? My last archetype is never used. Seems odd to me that no one had this problem so far. o_O
     
  33. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Yeah I have had this issue. What I did to get around it was add the bottom achetype twice. So it is used and the extra one on the bottom is not.
     
  34. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    You're absolutely right. Sorry about that, I'm not sure how that slipped past me :oops:


    I've pushed the fix to the Asset Store (it's still version 1.3.0 though), it should be approved in the next few days. Beware when updating if you've been working around the issue by duplicating the bottom archetype as they'll now both be used.
     
    Baldinoboy likes this.
  35. Mark_T

    Mark_T

    Joined:
    Apr 25, 2011
    Posts:
    303
    First of all, Thanks for this great asset!
    There are many scattering asset stores tools for Unity, but for vegetation/landscape wise, this is the best.
    The reason for my post is to ask if would be possible to integrate/ makeitwork with AltTrees System. It's still in beta, but looks very promising.
    Thanks!
     
    Baldinoboy likes this.
  36. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    AltTrees does look promising; I'll try to take a look at it soon and see if I can add it as an option.
     
  37. Mark_T

    Mark_T

    Joined:
    Apr 25, 2011
    Posts:
    303
    OOOOh, thank you!
    It'll be a match made in heaven. :)
     
  38. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Sorry, it might be a little while before I get AltTrees integration working; it's going to be a bit trickier than I first thought.
     
  39. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Especially since it is still in beta.
     
  40. gilley033

    gilley033

    Joined:
    Jul 10, 2012
    Posts:
    1,191
    Hello!

    I bought Landscaper a while ago and am just getting some use out of it now. It looks like a wonderful tool, but there are a few editor issues I wanted to bring to your attention.

    Most of these center around the fact that changing a value in one of the many fields of the "Foliage Area" script do not notify the Unity Editor that a change has taken place. The result is that the scene is not marked as dirty, and if you try to save the scene immediately, the change in value will not be saved if you exit the scene or Unity and reopen it.

    I am guessing this has not come up before because most users perform other actions in the scene (such as hitting the "Simulate" button) that cause the scene to become dirty, thus masking the issue.

    The easiest way to solve this is to convert your editor code to make use of the SerializedObject and SerializedProperty classes. These will give you some added functionality by default, such as marking the scene as dirty and providing undo support.

    The one other issue is that when creating a Foliage Area game object, again, the scene is not marked as dirty, and if the user tries to save immediately, the game object will not be there if they then exit the scene or Unity and reopen it. To be honest, I have no clue why this is happening, as I assume the scene should get marked dirty automatically when calling new GameObject.

    Again, great tool! I don't see these as major issues, and they will certainly not keep me from rating your package highly on the Asset Store once I get a better feel for it.
     
  41. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Thanks for pointing these issues out, I think I've solved all of them in the newest beta build.


    Version 1.3.1 (Beta)
    - Download

    - Bugfix [IMPORTANT] The "Layer" property of the FoliageArea was previously being incorrectly saved as a LayerMask. Your layer value may have changed after the update, be sure to check to make sure foliage is still set to spawn on the same layer
    - Bugfix Creating a new FoliageArea from the menu bar and changing properties on a FoliageArea should now correctly mark the scene as dirty, prompting you to save the scene when it is closed
    - Change All properties of the FoliageArea component now support undo/redo and all have tooltips
     
    Baldinoboy likes this.
  42. gilley033

    gilley033

    Joined:
    Jul 10, 2012
    Posts:
    1,191
    Awesome! Thanks for being so responsive
     
    hopeful likes this.
  43. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Hey @AegonGames ,

    Thanks for the update. I was wondering if it would be possible to have a percentage of occurrence for Archetypes for a species?

    For instance I have two grass patch models. One has flowers and the other does not. I do not want the flowers to show up that much but only 25% of the time.

    So would it be possible to have a percentage next to each Archetypes (default 100%) that the user can adjust to have a that model show up less than the other(s)? For now I think making additional Archetypes of the more wanted model will make it show up more but thinking if it is not too difficult this would be much better.

    Thanks
     
  44. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Yeah that's an easy enough feature to add, not sure why I hadn't already done it. It's implemented in the new beta build as a relative weight rather than a direct % chance (but the chance is displayed right next to it).

    Version 1.3.1 (Beta) - Download
    - Bugfix [IMPORTANT] The "Layer" property of the FoliageArea was previously being incorrectly saved as a LayerMask. Your layer value may have changed after the update, be sure to check to make sure foliage is still set to spawn on the same layer
    - Bugfix Creating a new FoliageArea from the menu bar and changing properties on a FoliageArea should now correctly mark the scene as dirty, prompting you to save the scene when it is closed
    - Change All properties of the FoliageArea component now support undo/redo and all have tooltips

    * NEW *
    - Feature Foliage archetypes now have their own weight value to adjust the likelihood that each archetype appears when planting a new foliage instance
     
    Baldinoboy likes this.
  45. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Awesome! Thank you so much
     
  46. Mark_T

    Mark_T

    Joined:
    Apr 25, 2011
    Posts:
    303
    Thanks a lot!
    Hopefully it can be done.
     
  47. SebastianMaj

    SebastianMaj

    Joined:
    Nov 28, 2013
    Posts:
    113
    Is there any chance of this working for spherical terrain/objects?
     
  48. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Unfortunately not - rays are only cast downwards; I'd need to re-write most of the code to make it work for spherical terrains.
     
  49. SebastianMaj

    SebastianMaj

    Joined:
    Nov 28, 2013
    Posts:
    113
    Alright, no worries! :) Thanks for letting me know. Seems like many assets don't support spherical terrains so I will have to develop most of the systems myself.
     
  50. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I just started using this and am seeing a strange issue. After foliage is placed on the terrain as Terrain Trees, some of the trees are upside down and underneath the terrain.

    upload_2017-5-24_8-27-20.png

    I didn't even know this was possible so I don't know how this could happen. Could this be a Unity terrain issue? Or a Landscaper issue? I am using Unity 5.5.3f1.