Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[FREE] Vegetation Spawner, procedural tool for the terrain system

Discussion in 'Assets and Asset Store' started by StaggartCreations, Aug 20, 2020.

  1. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,367

    A straightforward but powerful procedural vegetation spawner for the terrain vegetation system. Allows a terrain to be quickly populated with vegetation, without spending days on painstaking manual painting.

    Rule based spawning
    - Probability
    - Height range
    - Slope range (0-90°)
    - Curvature (convex/concave)
    - Water level rejection
    - Terrain layer masking
    - Collider rejection

    Features
    - Multi-terrain support
    - Can be executed at runtime
    - Precomputed scene collider checks

    Trees are defined as "species" and can have a number of prefabs, each with their own spawn chance. This allows variants of the same tree to be spawned with one rule set. Spawn points for the same species will never overlap!

    Limitations
    - Not equipped for biomes or region-specific spawning
    - Manually painted vegetation will be overwritten when respawning
    - Only works for square terrains

    Note: Vegetation/terrain assets seen in the screenshots are not included in this package.




     
    Last edited: Nov 7, 2020
  2. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,367
    Submitted to the asset store, but is pending review, this can take anywhere between 2 to 4 weeks.

    Price is a whopping $0, and will be free until it proves to require more time to support than is viable.
     
    Lars-Steenhoff and angrypenguin like this.
  3. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,367
  4. Nunggi

    Nunggi

    Joined:
    Apr 7, 2018
    Posts:
    6
    First of all, thank you for the free use.
    A problem occurred while trying.
    Add Prefab made with Unity Tree Creator
    Changes to the parameter can cause a fairly slow or unity to stop.
    Is there a solution to this?

    And in the case of trees placed with Vegetation Spawner,
    light and Post Processing do not seem to be affected.
     
    Last edited: Aug 27, 2020
  5. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,367
    Sorry, missed your message entirely, wasn't subscribed to the thread.

    Changing the spawn rules of a tree triggers a respawn of it, for a large amount of trees this takes <0.3 seconds. So that is a little slow, but its because a lot of things have to be done. But it ends up being a faster workflow being able to see the effect of a parameter directly.

    But it should not freeze Unity, it's best to always be careful with the distance and spawn chance parameters, because it's essentially possible to spawn millions of trees, which the terrain rendering can't handle.

    The tool only places vegetation of the terrain, so doesn't affect rendering. If you're having issues with rendering, even if you manually paint a tree on the terrain it's either because of the shader used on the tree, or the way the terrain renders vegetation.

    --------
    Submitted v1.0.1

    Added:
    - Grass items can now be duplicated
    - Exposed seed value in settings tab (global, added to each item's own seed)

    Fixed:
    - Last selected tree item respawning when changing grass spawn rules
     
  6. Fanttum

    Fanttum

    Joined:
    May 18, 2014
    Posts:
    37
    Great tool!
    Something I was surprised that wasn't built in so happy to see you've built this out.

    At first I had some issues, but then realized I was using a non-square terrain so once I made it square everything worked great.
     
    StaggartCreations likes this.
  7. ash4640

    ash4640

    Joined:
    Jan 19, 2018
    Posts:
    62
    First of all thanks for this wonderful asset
    just a couple of issues I faced
    - the trees I add are black in color not rendered properly, while placing the same trees using unity terrain tool, the three look fine. They are Il Trees variety pack - unity speed trees
    - also the grass has a default main color and secondary, is their a way to disable this, somehow it overrides the color of the default grass
     
    Last edited: Oct 20, 2020
  8. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,367
    You're welcome ;)

    I checked it out, and it appears trees need a specific "lightmap" color, by default this is black, and I'm not setting anything. I assume this is something the tree creator shaders use.

    In the VegetationSpawner.cs file, you can insert treeInstance.lightmapColor = Color.white; at line 385, then change a spawning parameter so the trees are forced to respawn with the new color value.

    Let me know if that pans out, if so I'll make the modification permanent.

    As for the grass color, the primary/secondary colors are always multiplied over the grass's texture color. So if your texture is that of a green grass tuft, the colors set for the grass should actually be white in order to fully retain the texture's color. Using a green color in this case will only make the grass appear darker.
     
  9. ash4640

    ash4640

    Joined:
    Jan 19, 2018
    Posts:
    62
    yes this got it working, great and thanks
    also couple more things on the grass spawning
    - the white I'm not sure if it is keeping the original grass textures color or adding a white tint to it, also tried setting alpha to zero it does not help, probably having an extra option (checkbox) to just use the original grass texture color will help, (if white does add some tint to the original color)
    - also when having multiple textures of grass if spawn percent of the first texture is 100 then setting the second texture any percentage (eg 20,100) will not spawn it, only the first texture is spawned on the terrain, eg if the first texture is 50 and the second texture is 50 then it spawns both the textures
    - when I have four textures and set 25% to each texture then the first textures does not get spawned
    - also even when setting 100% and spawning the grass there is always space between the meshes/textures, the density is less or does not cover the whole terrain
    - one bug: when changing a value in any field and going to the next object or texture then previously changed value for the previous mesh is visible in the current textures
    I own your grass, water and forest environment all are good assets, probably you could add some more features/rules and supporting all tree types speedtree, mtree etc make this like a indie friendly paid asset around 5 or something or you could even add object spawning make it like a cheaper version 10.
    - Also a discord can help for supports as it is very common these days, also I run a discord to help indie game devs, asset devs help promote their games and asset and network, with around 350 game devs now, you are welcome to join it as an Asset Dev
    https://discord.gg/qfKD939
     
    Last edited: Oct 21, 2020
  10. jso1980

    jso1980

    Joined:
    Nov 11, 2019
    Posts:
    13
    Helo,

    when using HDRP Im finding that the grass prefabs all turn white with no shader at all on them,
    can you please help
     
  11. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,367
    From what I gathered, grass generally doesn't work in HDRP, because there is no compatible shader. You can most likely get around this by adding the grass as a tree instead. This way you can use any shader you want.
     
  12. jso1980

    jso1980

    Joined:
    Nov 11, 2019
    Posts:
    13
    Thankyou it works when applied as a tree instead!

    Although I can't get many grass bits as much as I'd like since its a tree,
    Also the sink amount seems to not have any effect?
     
    Last edited: Nov 6, 2020
  13. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,367
    That's kind of a pitfall of the built-in vegetation system, you either can't have grass other than billboards with the default shader. Or a custom shader, but with a huge performance impact. I'd recommend to check out Nature Renderer, it uses the terrain's vegetation, but replaces its rendering completely and makes dense grass possible at little performance cost.

    For the random rotation and sink to work, the "tree" prefab must have a LOD group (even if it only has one LOD). Another little quirk ;)
     
  14. rostyslav00s

    rostyslav00s

    Joined:
    Jan 1, 2020
    Posts:
    2
    Hi! Can you please help a little bit? Is there is the possibility to display all spawned trees as a prefabs in the inspector? I need to spawn trees and display it at the inspector as a prefabs , so I can interact with it in play mode
    Thanks!
     
  15. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,367
    The spawned instances of a tree prefab are stored in the terrain's TerrainData, same as would be when manually painting them. So you could query this to get all instances of a specific prefab like so:

    Code (CSharp):
    1. using System.Linq;
    2. using UnityEngine;
    3.  
    4. public class GetTreeInstancesTest : MonoBehaviour
    5. {
    6.     public Object prefab;
    7.     public Terrain terrain;
    8.  
    9.     public TreeInstance[] instances;
    10.  
    11.     [ContextMenu("Get instances")]
    12.     public void Refresh()
    13.     {
    14.         instances = GetTreeInstances(terrain, prefab);
    15.     }
    16.  
    17.     public static TreeInstance[] GetTreeInstances(Terrain terrain, Object prefab)
    18.     {
    19.         if (!prefab || !terrain) return null;
    20.  
    21.         int prototypeIndex = -1;
    22.  
    23.         //Get the index of the given prefab
    24.         for (int i = 0; i < terrain.terrainData.treePrototypes.Length; i++)
    25.         {
    26.             if (terrain.terrainData.treePrototypes[i].prefab == prefab) prototypeIndex = i;
    27.         }
    28.  
    29.         if (prototypeIndex > 0)
    30.         {
    31.             TreeInstance[] instances = terrain.terrainData.treeInstances.Where(x => x.prototypeIndex == prototypeIndex).ToArray();
    32.             Debug.Log(instances.Length + " instances of " + prefab.name + " found");
    33.  
    34.             return instances;
    35.         }
    36.         else
    37.         {
    38.             Debug.Log("Tree prefab not found in " + terrain.name);
    39.         }
    40.  
    41.         return null;
    42.     }
    43. }
     
  16. rostyslav00s

    rostyslav00s

    Joined:
    Jan 1, 2020
    Posts:
    2
    Thank you! Works beautiful
     
  17. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    13,467
    Hey, just checking this out now. Thanks for making something so useful free!

    First impressions, which are somewhat project specific.
    • The UI seems really well designed. Info is displayed and entered in places that make sense for the workflow.

    • Performance seems pretty good. I've tried other tools which take minutes to populate a terrain of the size we're working with (~8km squared), where this does it in ~30 seconds.

    • That said, the auto-respawn when you change some properties is a pain with a terrain that huge. It'd be nice if that could be toggled on/off for when we're working with terrains too large to work in near-real-time.

    • Something else that'd be great is the ability to spawn GameObjects under a specified parent, in addition to terrain data objects.
     
  18. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,367
    Thank you for your feedback :)

    I've added an option under the Settings tab to disable the respawning of trees, when changing a parameter.

    I think managing the spawning of GameObjects would be outside of the scope of what I want this tool to achieve. But as an alternative, I'll add delegate events for when a grass or tree item respawns. This way it's possible to write custom post processing scripts on top of everything that can check for a specific prefab and do whatever they need.

    Example:
    Code (CSharp):
    1. using UnityEngine;
    2. using Staggart.VegetationSpawner;
    3.  
    4. [ExecuteInEditMode]
    5. public class EventTest : MonoBehaviour
    6. {
    7.     private void OnEnable()
    8.     {
    9.         VegetationSpawner.onTreeRespawn += OnTreeRespawn;
    10.         VegetationSpawner.onGrassRespawn += OnGrassRespawn;
    11.     }
    12.  
    13.     private void OnDisable()
    14.     {
    15.         VegetationSpawner.onTreeRespawn -= OnTreeRespawn;
    16.         VegetationSpawner.onGrassRespawn -= OnGrassRespawn;
    17.     }
    18.  
    19.     public void OnTreeRespawn(SpawnerBase.TreePrefab item)
    20.     {
    21.         Debug.Log(item.prefab + " Tree respawned");
    22.     }
    23.  
    24.     private void OnGrassRespawn(SpawnerBase.GrassPrefab item)
    25.     {
    26.         if(item.type == SpawnerBase.GrassType.Mesh) Debug.Log(item.prefab.name + " grass respawned");
    27.         if(item.type == SpawnerBase.GrassType.Billboard) Debug.Log(item.billboard.name + " grass billboard respawned");
    28.     }
    29. }
    I've added an extension function to the Terrain class, that returns all tree instances for a specific prefab, so it's possible to get it's spawnpoints.

    Code (CSharp):
    1. using Staggart.VegetationSpawner;
    2. using UnityEngine;
    3. using Object = UnityEngine.Object;
    4.  
    5. public class GetTreeSpawnpoints : MonoBehaviour
    6. {
    7.     public Object prefab;
    8.     public Terrain terrain;
    9.     private TreeInstance[] instances;
    10.  
    11.     private void OnValidate()
    12.     {
    13.         if (!prefab || !terrain) return;
    14.  
    15.         //Extension function from Staggart.VegetationSpawner.TerrainSampler class
    16.         instances = terrain.GetTreeInstances(prefab);
    17.        
    18.         Debug.Log(instances.Length + " instances found");
    19.     }
    20.  
    21.     private void OnDrawGizmos()
    22.     {
    23.         if (instances == null) return;
    24.        
    25.         for (int i = 0; i < instances.Length; i++)
    26.         {
    27.             Gizmos.DrawSphere(instances[i].position, 1f);
    28.         }
    29.     }
    30. }
    These two combined would make it possible to spawn GameObjects on trees.
     
    angrypenguin likes this.
  19. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    13,467
    Sweet! That makes this super flexible indeed.

    Thanks again!
     
  20. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,367
    Submitted v1.0.3

    Added:
    - Callback delegate for when a grass/tree item respawns (see documentation for example).
    - Terrain extension function for getting a tree instances of a specific prefab.
    - Water level is now visualized in the scene view when the Settings tab is active.
    - Option to disable automatic respawning of trees when a spawn rule is modified.

    Changed:
    - Renamed "Opacity threshold" for terrain layer masks to "Minimum strength", for clarity.
    - Height range maximum value is now based on the height of the largest terrain (instead of being fixed at 2000).
    - Collision detection now works for non-square terrains

    Fixed:
    - UI error when switching to a scene with fewer grass items than the last
     
  21. Black-Abyss

    Black-Abyss

    Joined:
    Nov 2, 2016
    Posts:
    12
    Any idea what this bad boy might be caused by? It happens on all my terrains, URP 8.2 running Unity 2020.1 latest release.

    Code (CSharp):
    1. ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    2. Parameter name: index
    3. System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <9577ac7a62ef43179789031239ba8798>:0)
    4. System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <9577ac7a62ef43179789031239ba8798>:0)
    5. Staggart.VegetationSpawner.VegetationSpawnerInspector.DrawTerrain () (at Assets/VegetationSpawner/Editor/VegetationSpawnerInspector.cs:206)
    6. Staggart.VegetationSpawner.VegetationSpawnerInspector.OnInspectorGUI () (at Assets/VegetationSpawner/Editor/VegetationSpawnerInspector.cs:156)
    7. UnityEditor.UIElements.InspectorElement+<>c__DisplayClass58_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <507f517ae7864f439b730eed1dbf6793>:0)
    8. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
    9.  
     
  22. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,367
    This is something that slipped by me and was caused by last update. I've already submitted a hotfix but it's still pending review unfortunately.
     
    Black-Abyss likes this.
  23. Roughrider

    Roughrider

    Joined:
    Jul 17, 2011
    Posts:
    73
    Getting the same thing here. Have a code change or a hotfix we can work with in the meanwhile? Using the latest version on the asset store as of this moment.
     
    Last edited: Dec 15, 2020
    Black-Abyss likes this.
  24. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,367
    Would you mind sharing the exact console error? I'm not seeing any errors when adding the component to a new GameObject and adding the terrain(s)
     
  25. Roughrider

    Roughrider

    Joined:
    Jul 17, 2011
    Posts:
    73
    *** EDIT: I found the old file and deleted it from my downloaded assets, and redownloaded the asset through the package manager. All working now. ***
    ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
    System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <9577ac7a62ef43179789031239ba8798>:0)
    System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <9577ac7a62ef43179789031239ba8798>:0)
    Staggart.VegetationSpawner.VegetationSpawnerInspector.DrawTerrain () (at Assets/VegetationSpawner/Editor/VegetationSpawnerInspector.cs:206)
    Staggart.VegetationSpawner.VegetationSpawnerInspector.OnInspectorGUI () (at Assets/VegetationSpawner/Editor/VegetationSpawnerInspector.cs:156)
    UnityEditor.UIElements.InspectorElement+<>c__DisplayClass58_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <507f517ae7864f439b730eed1dbf6793>:0)
    UnityEngine.GUIUtility: ProcessEvent(Int32, IntPtr, Boolean&)

    I am using the unity Terrain Tools Version 3.0.2-preview.3 - November 09, 2020 as well. Yet I just fired up a new project, adding veg spawner, made a 500x500 terrain, added an empty gameobject and added the spawner. Getting the same error when trying to add a terrain. Using unity 2020.1.15f1
     
    Last edited: Dec 15, 2020
  26. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,367
    I've read about some people downloading an update through the Package Manager in 2020.1, but it still downloads the older version, seems like you ran into the same bug. But deleting the local package is exactly the solution, so glad you've managed to figure that out!
     
  27. Black-Abyss

    Black-Abyss

    Joined:
    Nov 2, 2016
    Posts:
    12
    So I was working with the spawner normally and at some point this started popping up whenever I try to spawn or respawn a grass mesh: https://i.imgur.com/v7Wckto.png Any ideas what might be causing it?

    Code (CSharp):
    1. IndexOutOfRangeException: Index was outside the bounds of the array.
    2. Staggart.VegetationSpawner.Cell.GetSubcell (UnityEngine.Vector3 worldPos, System.Single cellSize, System.Int32 subDivisions) (at Assets/VegetationSpawner/Runtime/Cell.cs:74)
    3. Staggart.VegetationSpawner.VegetationSpawner.InsideOccupiedCell (UnityEngine.Terrain terrain, UnityEngine.Vector3 worldPos, UnityEngine.Vector2 normalizedPos) (at Assets/VegetationSpawner/Runtime/VegetationSpawner.cs:199)
    4. Staggart.VegetationSpawner.VegetationSpawner.SpawnGrass (Staggart.VegetationSpawner.SpawnerBase+GrassPrefab item) (at Assets/VegetationSpawner/Runtime/VegetationSpawner.cs:566)
    5. Staggart.VegetationSpawner.VegetationSpawnerInspector.DrawGrass () (at Assets/VegetationSpawner/Editor/VegetationSpawnerInspector.cs:569)
    6. Staggart.VegetationSpawner.VegetationSpawnerInspector.OnInspectorGUI () (at Assets/VegetationSpawner/Editor/VegetationSpawnerInspector.cs:139)
    7. UnityEditor.UIElements.InspectorElement+<>c__DisplayClass58_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <c84609c921cb488481d7d8a5fcdf9588>:0)
    8. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
    9.  
     
  28. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,367
    Was the terrain size changed by any chance? If so, you can go to the settings tab and hit the "Rebuild cache" button. I should probably do this automatically if a terrain was added/removed, or changed in size.
     
  29. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    38
    VegetationSpawner UI Bug.jpg VegetationSpawner UI Normal.jpg
    Code (CSharp):
    1. ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    2. Parameter name: index
    3. System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <9577ac7a62ef43179789031239ba8798>:0)
    4. System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <9577ac7a62ef43179789031239ba8798>:0)
    5. System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <9577ac7a62ef43179789031239ba8798>:0)
    6. Staggart.VegetationSpawner.VegetationSpawnerInspector.LayerMaskSettings (System.Collections.Generic.List`1[T] masks) (at Assets/VegetationSpawner/Editor/VegetationSpawnerInspector.cs:698)
    7. Staggart.VegetationSpawner.VegetationSpawnerInspector.DrawGrass () (at Assets/VegetationSpawner/Editor/VegetationSpawnerInspector.cs:555)
    8. Staggart.VegetationSpawner.VegetationSpawnerInspector.OnInspectorGUI () (at Assets/VegetationSpawner/Editor/VegetationSpawnerInspector.cs:139)
    9. UnityEditor.UIElements.InspectorElement+<>c__DisplayClass58_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <afa5b9a1793446ff98b741dc036c4c6e>:0)
    10. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    11.  
    Still super happy with this tool, the little things really count.

    We've found sometimes the UI doesnt refresh causing this error to flag, and UI segments vanish, this can also sometimes occur when just starting adding a terrain from the get go, but personally i havn't had any luck reproduce this in sometime.

    a work around is simply to just click off your spawner object and go back to it and it'll refresh.

    Hope that helps!
     
  30. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,367
    Thanks for the log details!

    I think it's possible this occurs if you have the inspector open, and something else deletes a terrain layers from the terrain. Possibly if you have the vegetation spawner open in one inspector tab, while using something like MapMagic to paint the terrain.

    Whenever you open the Vegetation Spawner in the inspector, the terrain layers are fetched gain from the first terrain, in case they've been changed.

    But in any event, I've added some improved checking, in case a terrain was used as a spawning rule, but was removed from the terrain:
    upload_2021-2-24_16-52-49.png
     
    HIBIKI_entertainment likes this.
  31. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    38

    Great find!
    No idea what causes it on my end
    Though we do use Nature Renderer on top, maybe they both run checks.

    For me i can only imagine i was clicking at blazing speeds! :D.

    Thanks for the input back too! Glad i can be of some help for you.
     
  32. Middelbo

    Middelbo

    Joined:
    Apr 30, 2013
    Posts:
    9
    Awesome tool! I'm trying to make it spawn trees on a flat terrain but there seems to be a bug where it will only spawn them on flat surfaces when I set the slope to the full range (0-90). If it's anything else, I get 0 trees on flat terrain.

    upload_2021-2-26_16-51-31.png
    upload_2021-2-26_16-52-12.png
     
  33. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    38

    interesting , i don't seem to be able to do this my self, but im also trying to make heads and tails of your screen shot.

    what happens when you set the slope range to 0-1 with no layer mask form your splat/t.layer?


    EDIT:
    upload_2021-2-26_16-12-37.png
    i see what you mean now.

    This may be intentional as i can't tell how this could be a "bad thing" .
    my advice would be to use the Height limite slider above, that way you can still use that primary terrain layer elsewhere but the spawn rules wouldn't effect heigher levels on the same terrain layer.

    EDIT 2:
     
    Last edited: Feb 26, 2021
  34. Middelbo

    Middelbo

    Joined:
    Apr 30, 2013
    Posts:
    9
    If I set the slope range to 0-1 with no layer mask I get the same result.

    I think I have found the reason in the code:
    upload_2021-2-26_17-7-7.png

    What purpose does that magic number serve?
     
  35. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    38
    ooo sorry @Middelbo , edited my response, i didn't realise you were that quick to reply, see if my edit helps :D
     
    Middelbo likes this.
  36. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    38
    @StaggartCreations just noticed "sink amount" doesnt seem to work for me, im in a preview area though, but FYI
     
  37. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,367
    Now that you mention it, I just realized I've already fixed this, but haven't gotten around to submitting an update yet. So I'll be sure to do so soon!

    Frankly, I forgot what it's for :p I'll see if I can make sense of it, my tests terrains never had any flat areas so I hadn't noticed. Thanks for the heads up!
     
    HIBIKI_entertainment likes this.
  38. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,367
    I can reproduce the same result in the current version on the store, but along the way this seemed to have been fixed in the new version. If the minimum slope is 0, trees will also spawn on areas that are entirely flat.

    Submitted v1.0.4

    Added:
    - Grass items now have a toggle for camera billboarding if a texture is used
    - Noise spread value for grass can now also be configured
    - Adding a tree now automatically opens a project prefab picker
    - Settings tab now has the option to only respawn all grass or trees
    - Added option to set the detail map resolution, since this control the minimum possible distance between grass items

    Changed:
    - UI improvements for usability
    - Renamed namespace to "sc.terrain.vegetationspawner" for consistency between other terrain tools
    - Secondary grass color value is now kept, even if linked to main color
    - Removed some terrain settings, the component should only concern itself with vegetation related settings (added more of those!)
    - (C#) SpawnerBase.GrassType.Billboard was renamed to SpawnerBase.GrassType.Texture. Since a grass item isn't always a billboard

    Fixed:
    - Sink amount for trees not having any effect
    - Inspector window being forced to a fixed width under certain circumstances in the grass tab
    - Layer mask selection not selecting the correct item in some cases
     
    Middelbo likes this.
  39. Middelbo

    Middelbo

    Joined:
    Apr 30, 2013
    Posts:
    9
    Just updated to 1.0.4. I'm sorry to say I still have the same issue.
    Repro steps:
    1. Create new scene
    2. Add a new terrain
    3. Create a Game Object with Vegetation Spawner component
    4. Add a tree prefab under the Trees tab
    5. See that there are no trees
    6. Turn the slope value from 60 to 90 and observe the terrain getting filled with trees
    upload_2021-3-1_14-13-29.png
    upload_2021-3-1_14-14-0.png
     
  40. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,367
    Thanks for the repo steps. I followed them, but the terrain still gets blasted full of trees when modifying the max slope value:
    upload_2021-3-1_14-22-45.png

    According to your screenshot, you are still on v1.0.3, so it seems you ran into the Package Manager bug that's floating around.

    You'd have to delete the cached package from C:\Users\<username>\AppData\Roaming\Unity\Asset Store-5.x\Staggart Creations\Editor ExtensionsTerrain, after which you can actually download the current version.
     
    Middelbo likes this.
  41. Middelbo

    Middelbo

    Joined:
    Apr 30, 2013
    Posts:
    9
    Ha! You're right! Thank you very much. I can confirm everything is fine now.
     
    StaggartCreations likes this.
  42. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    38
    Ah this bug is an absolute plague for Teams/Collab and those with large store databases, can go so unnoticed if you're not careful.

    Great steps on all the updates!
     
unityunity