Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct here to familiarize yourself with the rules and how to post constructively.

  2. Unity 2022.1 is now available as the latest Tech release.
    Dismiss Notice
  3. Improve your project's performance with our new guide on profiling in Unity.
    Dismiss Notice

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:
    573
    I didn't know that was possible either. Unfortunately, I haven't been able to reproduce the issue. The rotation of terrain trees can't even be set like that through code as far as I'm aware, the only rotation we have control over is the yaw (around the tree's up direction) so I don't know how that has happened.

    Google also hasn't turned up any results, so I'm not sure it's a Unity issue but I just can't see how a bug in Landscaper could cause that either.
     
  2. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,942
    Yeah, I couldn't find any results on Google either for Unity bugs on this. But I never saw this before using Landscaper so there must be something going on there that we just don't understand. For now I'm just finding the bad trees and removing them one by one, but it's a pain.
     
  3. gilley033

    gilley033

    Joined:
    Jul 10, 2012
    Posts:
    1,050
    What do you think about adding an option for having the spawned instances still be linked to the original prefabs? As it stands now they are not, so if you try to make a change to the original prefab, for instance changing it to be "Lightmap Static", you have to re-simulate the foliage area spawn operation in order to get the changes into the scene.

    Just a thought.
     
  4. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    998
    Great asset! Couple of questions

    - Is there a, or has anyone created a reporting tool? As I modify my species and re-simulate, I would like to know how many of any given species have been generated. I began write something but thought someone would have gotten to that point before me. Taking that a step further, toggling visibility per species to see what you are actually getting.

    - How do I fit the Foliage Area to a selection? You have to have the foliage area selected to use the inspector, so I can't also select my mesh? What am I missing?
     
  5. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    573
    There isn't a reporting tool at the moment, but I agree it would make a nice addition. Toggling visibility could be a little tricky when using Unity terrain trees - since I can't keep a reference to them, there's no way to know which trees where placed by Landscaper or which species the tree belongs to.

    To fit to a selection, you can lock the inspector by clicking on the padlock icon in the top-right corner of the inspector window; that'll prevent it from updating with your new selection.
     
  6. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,942
    @Aegon-Games I'm suddenly having an issue. I was experimenting with placing trees as Game Objects on one scene in my project, but I didn't like the results so I changed all my trees back to Terrain Trees. Now, I'm using this Species definition in a new scene and when I simulate the trees they all appear as game objects instead of terrain trees. I double checked everything and it is all set correctly, but the trees still show up as game objects. See in this screenshot where my species trees are all terrain trees, bu in the scene hierarchy you can see them all as game objects.

    upload_2018-10-12_8-36-32.png

    [EDIT]
    I decided to debug this and it's not quite what I thought. I output to the console whether a tree is going to the terrain or as a game object and almost all of them go to the terrain, but some go as game objects. Now, I understand in Limit mode that it would do this if the count exceeds 65.535, but the total instances are only 20,563 so I have no idea why some of these are going as game objects and other are not. Again, I checked each tree definition and they are all set to terrain tree.

    [EDIT2]
    I figured out the cause. I had a Plane representing a frozen lake area and that has a box collider on it and the layer is the same layer as the terrain. So it was placing trees on the mesh. I didn't realize that was possible. So, I'm changing my terrain layer to its own layer and that should fix it.
     
    Last edited: Oct 12, 2018
  7. r3ndesigner

    r3ndesigner

    Joined:
    Mar 21, 2013
    Posts:
    142
    Hello aegon, i sent you an email, regarding the asset.
     
  8. Win3xploder

    Win3xploder

    Joined:
    Dec 5, 2014
    Posts:
    128
    Can you add a faster flood fill option? That would be really useful for adding ground cover like fallen leaves, pine needles or little stones and stuff. Right now, adding that sort of thing to the simulation leads to long processing times.

    Would really appreciate that feature!
     
    Last edited: Feb 6, 2021
  9. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    573
    That would definitely be a nice feature to have. I was planning something similar a few years ago for grass that would scatter meshes randomly across the whole terrain, but only render objects that were close. It's been so long that I don't remember what happened with that, but it didn't make it into the asset for some reason.

    I'll see what I can do. Unfortunately, I can't promise anything right now since there's another project eating pretty much all of my time at the moment.
     
    Win3xploder and Baldinoboy like this.
  10. Win3xploder

    Win3xploder

    Joined:
    Dec 5, 2014
    Posts:
    128
    Another really useful feature I'd like to have would be being able to click in the scene view and then having a seed be spawned at that position, with the resulting spawned objects being in a separate group to keep it non-destructive. A painting feature sort of.
     
  11. Win3xploder

    Win3xploder

    Joined:
    Dec 5, 2014
    Posts:
    128
    I figured out that by setting generations to 1 and children to 0-1 you can cover a large area with scatter assets without too much computation time (~30s)!
     
    Baldinoboy likes this.
  12. Exeneva

    Exeneva

    Joined:
    Dec 7, 2013
    Posts:
    432
    Having issues getting anything other than the first tree in my biome to spawn.

    upload_2021-4-14_10-58-37.png

    The foliage area covers my purple island:

    upload_2021-4-14_10-58-53.png

    After clicking Simulate All, I get 110 instances of the same tree, but not the second tree that should have a greater weight:
    upload_2021-4-14_11-0-35.png

    Using Unity 2021.1.3f1
     
  13. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    573
    I haven't been able to reproduce the issue on my end using the same Unity version.

    Does your second tree have its 'Placement Mode' set to 'Terrain Tree'? If Landscaper is told to place it as a terrain tree but the prefab isn't set up to be used as one, it just won't show up on the terrain.

    Are there any warnings or errors logged to the console?
     
  14. Exeneva

    Exeneva

    Joined:
    Dec 7, 2013
    Posts:
    432
    Gameobject spawn. Nothing in console.

    I recreated everything, and now I can spawn 2 of the second tree even though its weight is 0.6 and the first tree's weight is 0.4

    upload_2021-4-16_9-44-58.png

    upload_2021-4-16_9-47-20.png

    upload_2021-4-16_9-45-35.png

    upload_2021-4-16_9-45-52.png

    upload_2021-4-16_9-46-20.png
     
  15. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    573
    Looks like the problem is your 'Initial Seed Density' setting in the species asset. It's very high compared to the default value of 0.0003. The first species is filling up the entire available space with the initial batch of seeds before the second species ever gets a chance.

    Try lowering the 'Initial Seed Density' - even 10x the default value is enough to completely cover my test terrain. If your trees still aren't close enough together, take a look at the 'Shade Range' setting (also in the species asset). By default, trees can't grow in each others shade so lowering the shade range will allow your trees to spawn closer together.

    LowDensity.png
    HighDensity.png HighDensity_LowShadeRange.png
     
  16. Exeneva

    Exeneva

    Joined:
    Dec 7, 2013
    Posts:
    432
    Changing the seed density and shade ranges helped a little. However, I'm noticing that no matter what seed I set, the trees always spawn roughly in the same locations.

    upload_2021-4-20_15-47-3.png

    No matter what seed I select, the above circled areas are always empty and the trees always spawn in the same general locations.

    Settings:

    upload_2021-4-20_15-47-44.png

    upload_2021-4-20_15-48-1.png

    upload_2021-4-20_15-49-29.png

    upload_2021-4-20_15-49-49.png
     
  17. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    573
    Unfortunately I haven't been able to reproduce the results you're seeing. I copied your settings and was able to get wildly different tree placement when changing the seed value - no space was left empty every time.

    This image should animate. If it doesn't loop you might need to refresh the page to start it again.
    LandscaperSeedTest.gif

    The only thing I can think of is that Landscaper is trying to place trees on those areas, but the placement is being discarded for some reason.

    There are only a few possible reasons for rejecting a location. Slope angle and altitude probably aren't the reason - it looks like some of your trees are on steeper slopes and lower/higher altitudes than the affected areas. That leaves only the terrain texture mask (in the species settings) and the placement layer mask (in the foliage area settings).

    You can check if the terrain mask is the culprit by temporarily removing the mask from the species settings.

    It doesn't look like it from your screenshots, but is it possible that there are some objects that might be blocking raycasts coming from the top of the foliage area volume at the affected areas?
     
  18. Exeneva

    Exeneva

    Joined:
    Dec 7, 2013
    Posts:
    432
    What is the placement layer mask used for? It's not described in the documentation.

    upload_2021-4-24_17-14-50.png
     
  19. Exeneva

    Exeneva

    Joined:
    Dec 7, 2013
    Posts:
    432
    I see, so my issue is that my terrain is on its own layer, whereas my rocks and other gameobjects were on the Default layer, so it always spawned the trees in the same places as my rocks.

    Is there a way to add a Texture Exclusion rule? Now the issue I'm having is that it's spawning on some areas where the texture is blending with a rock texture, but I don't want the spawns to happen there. Even better would be a way to have density requirements on texture inclusion/exclusion rules like Vegetation Studio Pro does.
     
    Last edited: Apr 26, 2021
  20. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    573
    Glad you figured out the issue.

    There's no texture exclusion option right now, but I don't see why I couldn't add that functionality. I'll take a look tomorrow. The hardest part is probably going to be figuring out what to do with textures that aren't on the list and also making sure any changes I make don't brake existing projects.
     
    Exeneva and Baldinoboy like this.
  21. Exeneva

    Exeneva

    Joined:
    Dec 7, 2013
    Posts:
    432
    I think that's probably why VS Pro has texture density settings.

    For example, on the texture include rules, you have to specify a minimum texture density (like 0.1) and maximum texture density (like 1.0). The same goes for the texture exclude rules.

    If no include textures are set, it assumes all textures except for the excluded textures are fair game.
    If ANY include textures are set, it will only spawn on the include textures within the given density rules.

    Where the two are used together is in cases where you have a transition from one biome to another, like grassland to beach, and you want to spawn on the grass texture but not where there is any trace of sand texture. Hopefully that makes sense.
     
  22. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    573
    Landscaper 1.4.0 (Beta 2) - Download
    Available on the Asset Store as of 21 June 2021
    This version contains changes to underlying data structures. Asset data should be upgraded to the new format automatically but it's highly recommended to only use beta versions with a copy of your project to avoid potential data loss - downgrading to an earlier version is not supported.

    Features
    • Terrain texture masks section has been replaced with terrain layer density rules
      • Can now be set up by terrain layer (in Unity 2018.3+) in addition to texture or index
      • Now use a density multiplier for each layer to give more control over where (and how much) a species can spawn based on the terrain layers
      • A default density can be provided for layers which don't appear in the list

    • [New in Beta 2] (Experimental) Procedural grass placement component (Component > Landscaper > Experimental > Grass Placement)
      • Procedurally spawns GameObject instances on to a terrain in an area around the component
      • Supports multiple grass types and various constraints

    Enhancements
    • Added tooltips for all species properties


    I wanted to get this out as quickly as possible so I haven't updated the documentation yet. Here's a rundown of how the new terrain layer density feature works for the moment (still open to changes based on feedback):

    Each species has an optional list of densities per terrain layer. If the list is empty, instances will be planted at full density on every terrain layer as normal. There is a default density slider for any terrain layers that haven't been included in the list.

    The 'Combine Density' mode determines what density to use in cases where multiple layers have some weight painted - here's an example of how each option works:

    Assuming the potential spawn point is 60% grass and 40% rock, density on grass is 1, density on rock is 0:

    Blend (Default)
    Blends the densities based on the weight of each terrain layer. Density = (0.6 x 1) + (0.4 x 0) = 0.6

    Min
    The lowest density will be chosen. Density = 0
    Use this if you don't want foliage to grow if there's ANY rock

    Max
    The highest density will be chosen. Density = 1
    Use this if you want foliage to grow if there's ANY grass
     
    Last edited: Sep 3, 2021
    Baldinoboy and Exeneva like this.
  23. Exeneva

    Exeneva

    Joined:
    Dec 7, 2013
    Posts:
    432
    It's not recommended to use Landscaper for actually spawning grass on the terrain, is it?
     
  24. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    573
    I wouldn't recommend it, no. I haven't really tried spawning grass like this, but I think that would just be too many game objects. I'm hoping to finally have a proper solution for this built in to Landscaper soon though.

    A long time ago I made a very early prototype of a system for placing grass and other small detail objects only in the area around the player (the component is actually still in there under 'Landscaper/Experimental/Grass Placement'). In its current state it's really bad - it's slow, only spawns 1 prefab, and plants grass on top of trees - but I've been looking into making it a proper feature recently. Ideally it'll make it in to 1.4 but I'm not sure just yet.
     
    Baldinoboy and Exeneva like this.
  25. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    573
    Just released a new beta build of Landscaper 1.4 (Beta 2) which overhauls the (still experimental) grass placement component. Documentation has also been updated. See original post.
     
    Exeneva and Baldinoboy like this.
  26. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    115
    Hello @Aegon-Games, I've been interested in your assets, specifically as a solution for grass placement (I'm using my own tools for larger stuff like trees). I've been trying a few different assets and most have been either too convoluted/demanding, or only support terrains (I need to support terrains and meshes).

    I wanted to double check before purchasing, does your grass/small item placement work with meshes and terrains? And is it juggling a ton of gameobjects or is there some sort of draw instancing going on? Thanks!
     
  27. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    573
    The grass placement is still pretty experimental and it currently only supports terrains, sorry. Placing instances on meshes would require raycasts and that's not really an option when working with thousands of grass instances.

    One solution might be to bake a sort of custom heightmap for the entire scene in-editor and read from that at runtime, but I haven't even looked into doing something like that yet so I'm afraid Landscaper isn't going to work for your use-case.

    For how the grass is placed: instances are pulled from a pool of gameobjects that are moved into position in a a grid that follows the player around. I tried rendering mesh instances without gameobjects but it ended up being slower - not sure exactly why, but I think Unity might be able to optimise culling better for gameobjects that persist between frames. I'm planning to give this another shot at some point, but do my own frustum culling first to avoid passing a load of instances for Unity to handle - but I have no idea if that would even be faster.
     
    Noogy likes this.
  28. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    115
    @Aegon-Games, thanks for the reply.

    Your solution for meshes is actually a bit like what I'm doing for larger objects right now... I'm storing the transform data in a separate file and then either drawinstance/pooling gameobjects, based on distance. I wouldn't mind doing the same for grass but I worry about the size of the data files. Even with lower precision I worry about storing the positions of that much grass.

    That said, I'm still interested to see your solution for grass on terrains and will probably pick up the asset tonight. Are you randomly sampling the terrain heightmaps around the player, or doing something more clever with the terrain data? I would personally love to do that sort of thing via shader but it's a bit beyond me.
     
  29. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    573
    I'm just sampling the heightmaps - the XZ position that I'm sampling from is just a grid pattern with a random offset. The grass instances are batched into cells in a uniform grid and I'm keeping track of the player's position so that it only updates the grass instances when the player enters a new grid cell. I'm pretty much moving grass instances from cells that are now too far away from the player into newly relevant cells that are closer to the player.
     
unityunity