Search Unity

[RELEASED] Vegetation Studio

Discussion in 'Assets and Asset Store' started by LennartJohansen, Jun 23, 2017.

Thread Status:
Not open for further replies.
  1. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi. I will add the option to use colliders on the edit vegetation also. You can use that when painting grass/plants already.
    Thanks for finding this. It should have worked like this.

    Lennart
     
  2. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    487
    Does VS give the flexibility to add snow? I have been looking for a good package to enable me to build all environments.
     
  3. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Development update

    I just submitted a new update for Vegetation Studio. It is probably online tomorrow after review.

    Improvements
    • Added VegetationSourceID for Voxeland
    • Added static functions to Add a Vegetation System to a terrain in run-time
    • Added static functions to set up VegetationStudioManager
    • Advanced setting for automatic starting vegetation system when loading a scene or exiting play mode
    • Added ThreadUtility class
    • ShadowMaskCreator can now handle "unlimited" number of vegetation item instances when generating the shadow mask.
    • VegetationMaskLines can now have disabled segments and per segment width
    • Added Amplify node for Touch React system, for 3rd party grass shaders.
    • Added RefreshVegetationModelInfoMaterials to the VegetationStudioManager.
    • Grass, plants and objects with multiple submeshes can now render instanced indirect.
    Integrations
    • Added some API changes for integration with MapMagic.
    • Added some additional Vegegetation Mask line options for EasyRoad3D integration.
    Changes
    • Changed Additional mesh max distance from 700 to 1000 meter.
    • Small render loop optimization on computeshaders.
    • PersistentVegetationStorage package can now be set to auto init.
    • Changes for multi threaded access to PersistentVegetationStoragePackage
    • Added static functions on VegetationStudioManager to set sunlight on VegetationSystems
    • Changed default layer for touchbend from 31 to 29 to fix a problem with enviro
    • Original MaterialPropertyBlock is now read from Renderer component in prefab
    Fixes
    • Fix for error when PersistentVegetationStoragePackage is in memory only
    • Persistent storage component not getting reference to VegetationSystem if created in playmode
    • Fixed small issue with normals on billboards. needs regeneration.
    • Fixed compile error on
    • Fixed UI bug in inspector with billboards disabled
    • Fixed VegetationPackageList not initalized early enough
    • Fixed issue with UseTerrainTextures on VegetationPackage not possible to disable
    • Fix for compile error on TerrainHeatMap.shader on vulcan.
    Lennart
     
  4. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi.

    You can create multiple vegetation packages and switch between these run-time. This allows you to make a summer and a winter package and switch between them. As long as the spawning rules and seed are the same the summer and winter trees will then spawn at 100% the same location.

    Lennart
     
    blitzvb and recon0303 like this.
  5. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,634
    I use this very helpful. and easy to use.
     
  6. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    MapMagic integration

    Denis just finished a output node for MapMagic that allows you to feed the output of MapMagic generation direct to VegetationStudio for rendering. This can be combined with the run-time spawning of VegetationStudio, and all the masking features like VegetationMasks.

    Have a look at how the integration works.



    The output node is compatible with the version of Vegetation Studio that was submitted to asset store earlier today.

    Lennart
     
    Mark_01, blitzvb, AndyNeoman and 5 others like this.
  7. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    hello! how to update it when its allreadybin a project?
     
  8. Suavomirro

    Suavomirro

    Joined:
    Dec 3, 2012
    Posts:
    61
    Hi, so today my boss finally bought me fresh new copy of Vegetation Studio and after importing plugin from asset store, I don't have it anchored in window tab( screen 1). Also there are some console bugs (screen 2). One of our programmers will try to check the code but I decided to post it on the forums so maybe help will be faster.
    EDIT: problem solved. There was other bilboard system which we deleted and after compile, tab in window showed up.
     

    Attached Files:

    • 1.png
      1.png
      File size:
      21.2 KB
      Views:
      850
    • 2.png
      2.png
      File size:
      57.3 KB
      Views:
      847
    Last edited: Mar 9, 2018
  9. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Update on top of the old package should work.
    If you have any problems delete the Awesome Technologies folder and import again.

    Make sure that all your vegetation packages are saved outside of this folder before you delete it.

    Lennart
     
  10. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Instanced GI rendering

    Hi. I wanted to preview a feature I am working on for Vegetation Studio.
    Unity 2018.1 allows for instanced rendered meshes to sample GI from Unity light probes and use in rendering.

    In the example scene bellow 4 cubes are set up with an red emissive material and baked to Real-Time GI.
    There are also lightprobes set up in the scene.

    Settings will be on the Advanced tab of the VegetationSystem Component.
    This should work on any Vegetation Item set to "Instanced" rendering.

    Lennart



     
    Last edited: Mar 9, 2018
  11. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Thanks!
     
  12. zelmund

    zelmund

    Joined:
    Mar 2, 2012
    Posts:
    437
    was real pain to solve that problem in 5.6
     
  13. blitzvb

    blitzvb

    Joined:
    Mar 20, 2015
    Posts:
    284
    Cool! Does that work for billboard too?
     
  14. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    No. The billboards are batched together in meshes, you can only assign one probe sample per mesh/instance when rendering.

    Lennart
     
  15. Alexey1B

    Alexey1B

    Joined:
    May 15, 2017
    Posts:
    26
    Hi, i trying to change tint for grass of Advanced Foliage Pack 1 (too light/bright) in VS, there no option to tune it at VS tab like for usual grass. And VS shaders from Advanced Foliage Pack 1 - Advanced [grass/light] vegetation studio has color settings, but edit as vector value is not convenient
     
  16. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi

    Vegetation Studio does not know what parameters is available on 3rd party shaders.
    We are looking at a system where developer can implement a shader controll class that implements an interface.
    This way the developer can select what parameters he wants to expose to the VegetationStudio Inspector GUI.
    Settings will then be serialized in the vegetation package.

    This is still on prototype stage. Until we get a solution like this you will have to adjust the setting direct on the prefab grass material. Settings will update when you start VegetationStudio or enter playmode.

    Lennart
     
    MostHated likes this.
  17. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    does my vegetation package also know where they were placed on my terrain and wich parameters?
     
  18. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    The vegetation packages holds info about all the trees, grass and plants you added to it. It has the rules to spawn the vegetation on the terrain.

    To hold manual painted vegetation you need to create a persistent storage. These are one per terrain and holds all the instances added manually, by the API or baked from the rules.

    Lennart
     
    mattis89 likes this.
  19. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Thanks I got it all sorted out =)

    One thing tough I wonder wich I think is a shader instance indirect error bug, maybe I have to add that line, but Im gonna post a pic anyways , so =)

    oops deleted the picture but in play mode when I run around objects can appear in front of me glitchy, like in the middle of the screen, like they shouldnt be there..
    ...?
     
  20. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Send me a pm with a screenshot and I will try to see what it could be.

    Lennart
     
    mattis89 likes this.
  21. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Trying to find the best way to query directly for vegetation items within a distance from position. Or alternatively just the best way to get the entire list easily, and I can stick it in a spatial hash and query it there.
     
  22. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    hey! what was the tree chopping situation? I need a smaller set of trees to be choppable... must I bake my veg? and make the certain types of trees to objects and then add your beautifully made script to them? :)
     
  23. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi.
    Added a function to the API now.

    Add this function to the VegetationStudioManager.cs file.
    It will return all instances of the VegetationItem in all cells that overlap the bounds you provide.

    Lennart

    Code (csharp):
    1.  
    2.  
    3.         /// <summary>
    4.         /// This will return all instances of a VegetationItem in cells that overlap the provided bounds.
    5.         /// </summary>
    6.         /// <param name="bounds"></param>
    7.         /// <param name="vegetationItemID"></param>
    8.         /// <param name="includePersistentStorage"></param>
    9.         /// <returns></returns>
    10.         public static List<Matrix4x4> GetVegetationItemInstances(Bounds bounds, string vegetationItemID, bool includePersistentStorage)
    11.         {
    12.             List<Matrix4x4> instanceList = new List<Matrix4x4>();
    13.  
    14.             if (!Instance) FindInstance();
    15.             if (Instance)
    16.             {
    17.                 Rect areaRect = RectExtension.CreateRectFromBounds(bounds);
    18.                 for (int i = 0; i <= Instance.VegetationSystemList.Count - 1; i++)
    19.                 {                  
    20.                     List<VegetationCell> overlapVegetationCellList = Instance.VegetationSystemList[i].VegetationCellQuadTree.Query(areaRect);
    21.                     for (int j = 0; j <= overlapVegetationCellList.Count - 1; j++)
    22.                     {
    23.                         instanceList.AddRange(overlapVegetationCellList[j].DirectSpawnVegetation(vegetationItemID, includePersistentStorage));
    24.                     }
    25.                 }
    26.             }
    27.             return instanceList;
    28.         }
    29.  
    30.  
     
    blitzvb likes this.
  24. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi. You do not have to bake the vegetation. The script example in the demo works with both baked and run-time spawned.

    Just send me a pm is you have any problem setting this up.

    Lennart
     
    mattis89 likes this.
  25. PeterB

    PeterB

    Joined:
    Nov 3, 2010
    Posts:
    366
    Hi, when I import the new VS version, I get three errors, which persist even when deleting the Awesome tech folder and reimporting:

    Screen Shot 2018-03-11 at 19.01.42.png

    Mac, High Sierra, Unity 2017.3p3.
     
  26. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Go to player settings and defines. Then remove the VEGETATION_STUDIO define. MapMagic think that VS is still installed.

    Lennart
     
  27. PeterB

    PeterB

    Joined:
    Nov 3, 2010
    Posts:
    366
    Worked like a charm. Thanks for the speedy reply!
     
  28. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Very nice, thanks much, and loving your product!
     
  29. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Is it any benefitials to bake the terrain? other than to move stuff around? .... do I bake in the Persistent vegetation storage component / Bake Vegetation?
     
  30. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    @LennartJohansen
    I just updated to the latest version and it seems it did not quite work for the Vegetation Line Masks. On messing around looking for the issue it looks like some of the line segments are not enabled. They also show as a different size? When I enable them they seem to the work fine.


    upload_2018-3-12_17-42-43.png
     
  31. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Im like gonna wait to update til theres no issues :D
     
  32. DirtyHippy

    DirtyHippy

    Joined:
    Jul 17, 2012
    Posts:
    224
    Very cool stuff. However -

    Is there any intention of ever removing the memory allocations that are rampant, presumably as cells are populated? And optimizing the CPU costs of filling cells? Right now you can just move around the demo and just watch frames in the profiler with 100k+ memory allocated along with huge CPU costs for those frames. Memory allocation is rampant. I also tried baking the vegetation and while that seemed to help, there were still significant memory allocations occurring.

    I presume there is some spatial subdivision occurring, probably just a grid, and you have some roaming window of "cells' that moves around the terrain. It strikes me it would be fairly trivial to move the cells leaving the window to the side being generated and to reuse their matrix lists, etc so once you hit a steady state no more allocations would occur.
     
    cygnusprojects likes this.
  33. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi. Thanks for the info. I will look at it. The individual width and enabled was added as part of the integration with EasyRoads3D, to allow for vegetation under bridges without the need of multiple lines.
    I looked at the node struct and it shoud upgrade automatic, but I guess something is wrong. Does it happen with new LineMasks you create?

    Lennart
     
  34. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi. The work on a cell cache that pre allocates the needed memory is 80% done. The individual cells will then get a pre allocated cache object when spawning and return that for invisible cells when out of cache range.

    With this structure changes I am also preparing for a Unity 2018.1 + version of the cache/cell classes that will be using NativeArrays/Lists. This will remove most of the initial cache heap allocations also.

    I will be doing an update at the end of this week, it will not be included in this but I think it should be ready for the next.

    Lennart
     
    blitzvb and mattis89 like this.
  35. smada-luap

    smada-luap

    Joined:
    Aug 22, 2013
    Posts:
    945
    I've just loaded this up into Unity (been a while since I've been on the PC) and after looking over the demo scene everything looks very promising for future use - especially with the right terrain shader and textures so the grass texture on the terrain in the distance blends in with the grasses, etc. that are being used so there's no noticeable change when the rendered grass stops

    Now to go away and read through the docs and watch the various videos to get a handle on how I can start using this :)
     
  36. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    340
    Did you try using it? I need to access my trees in a given bounding box (not around camera) so this should be handy. However, I have no idea what to do with matrix4x4's.
     
  37. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    You can extract the instance position from it and use with the API.
    I will make an example when I am back in the office tomorrow.

    Lennart
     
  38. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    So what I ended up doing was to just create a persistent storage and use that data to query on.

    First I load them all and save them into instances of my own class, which being multiplayer I have anyways. It's easier to work with the data when it's flat rather then have to go through the structure VS has it in.

    Code (csharp):
    1.  
    2. public void LoadFromStorage()
    3.         {
    4.             ResourceItems.Clear();
    5.             int count = 0;
    6.             int cellCount = 0;
    7.  
    8.             VegetationPackage vegetationPackage = VegetationSystem.CurrentVegetationPackage;
    9.  
    10.             foreach (PersistentVegetationCell cell in Storage.PersistentVegetationStoragePackage.PersistentVegetationCellList)
    11.             {
    12.                 foreach(PersistentVegetationInfo info in cell.PersistentVegetationInfoList)
    13.                 {
    14.                     VegetationItemInfo itemInfo = vegetationPackage.VegetationInfoList.FirstOrDefault(p => p.VegetationItemID == info.VegetationItemID);
    15.                     //Debug.LogFormat("Name:{0}", itemInfo.Name);
    16.                     foreach (PersistentVegetationItem item in info.VegetationItemList)
    17.                     {
    18.                         var resourceItem = ToResourceItem(item, (int)itemInfo.VegetationType);
    19.                         ResourceItems.Add(resourceItem);
    20.                         count++;
    21.                     }
    22.                 }
    23.                 cellCount++;
    24.             }
    25.  
    26.             Debug.LogFormat("Cells:{0} Items:{1}", cellCount, count);
    27.         }
    28.  
    You can see how matrix conversion works from this, just ignore the extra stuff going on that's my own logic. Two versions one for matrix directly and another for the storage representation.
    Code (csharp):
    1.  
    2. public ResourceItem ToResourceItem(Matrix4x4 matrix, int vegetationType)
    3.         {
    4.             ResourceItem resourceItem = new ResourceItem();
    5.             resourceItem.VsType = vegetationType;
    6.             resourceItem.ClientPosition = MatrixTools.ExtractTranslationFromMatrix(matrix);
    7.             resourceItem.Position = resourceItem.ClientPosition.ToPoint3D();
    8.             resourceItem.Scale = MatrixTools.ExtractScaleFromMatrix(matrix).ToPoint3D();
    9.             resourceItem.Rotation = MatrixTools.ExtractRotationFromMatrix(matrix).eulerAngles.ToPoint3D();
    10.             return resourceItem;
    11.         }
    12.  
    13.         public ResourceItem ToResourceItem(PersistentVegetationItem item, int vegetationType)
    14.         {
    15.             ResourceItem resourceItem = new ResourceItem();
    16.             resourceItem.VsType = vegetationType;
    17.             resourceItem.ClientPosition = item.Position + Terrain.activeTerrain.transform.position;
    18.             resourceItem.Position = resourceItem.ClientPosition.ToPoint3D();
    19.             resourceItem.Scale = item.Scale.ToPoint3D();
    20.             resourceItem.Rotation = item.Rotation.eulerAngles.ToPoint3D();
    21.             return resourceItem;
    22.         }
    23.  
    And this is a distance query. You could do a bounds query easily also.
    Code (csharp):
    1.  
    2. public ResourceItem GetNearest(Vector3 position)
    3.         {
    4.             ResourceItem best = null;
    5.             float bestDistance = 1000f;
    6.             foreach (var plant in ResourceItems)
    7.             {
    8.                 float distance = (position - plant.ClientPosition).sqrMagnitude;
    9.                 if (distance < bestDistance)
    10.                 {
    11.                     bestDistance = distance;
    12.                     best = plant;
    13.                 }
    14.             }
    15.  
    16.             return best;
    17.         }
    18.  
    Also, a minimal masking implementation. I mask a lot of stuff, the components that come with VS are great but too heavy for my needs.
    Code (csharp):
    1.  
    2. public void MaskPoint(Vector3 position, float radius, VegetationType vtype)
    3.         {
    4.             CircleMaskArea mask = new CircleMaskArea
    5.             {
    6.                 Radius = radius,
    7.                 Position = position
    8.             };
    9.             mask.Init();
    10.             mask.VegetationType = vtype;
    11.             VegetationStudioManager.AddVegetationMask(mask);
    12.         }
    13.  
     
  39. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    The code he posted didn't quite work for me, it was being filtered somehow it looked like it was returning items by cell boundary but not getting all cells that overlap the world bounds.

    But in any case IMO it's just easier to load it all up into a flat structure on scene load if you are going to be doing of querying.
     
  40. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    I just did a few tests creating a new linemask and did not see the problem occur.

    Update:
    I was just running through all the line masks and noticed that they all seemed to fail to update correctly after the 4th node.
     
    Last edited: Mar 12, 2018
  41. Dorian-Dowse

    Dorian-Dowse

    Joined:
    Jun 2, 2016
    Posts:
    95
    It looks like the thumbnails on the Select Vegetation list are constantly updating. You probably won't notice this if you have 3 trees and 4 grasses, but in my current map I have 60 objects in the list and there is a 2 to 3 second delay after any action. I'm presuming it's the list thumbnails because I can see them updating during the lag. It makes working with VS very frustrating.

    I would prefer a text list over the thumbnails. It's too hard to recognize trees in the thumbnails. The text list could be sorted, and have enable boxes on each item. Also, to borrow an idea from audio mixing, it would be good to have a "Solo" button on each item. This would turn off everything except the selected item. Handy for tweaking a particular item.

    And it would be good to always have assess to "Enable all" and "Disable all".

    While we're at it, a Generate button and Auto-generate tick box, like on the Lighting panel, would let us make a bunch of changes before regenerating VS. Currently when I have everything on, any change requires several seconds to regenerate.
     
    mattis89 likes this.
  42. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    340
    Thanks, I'll wait for his explicit example!
     
  43. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    yes I noticed the same... very laggy
     
  44. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi. I have been looking at the Icon cache class and there seem to be a case where if Unity is not able to provide a Preview it will keep trying at every refresh. I will test if this could be the case and provide a fix.

    EDIT: I have a new version of the cache class. I will do a bit more testing. If someone has this issue and is online now I have a version for testing.

    Lennart
     
    Last edited: Mar 13, 2018
  45. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    1. I will see if I can fit the name in the thumbnail grid somehow. Good idea to make it a bit easier to select.

    2. A function for disable all other is on the list already.

    3. You can do this. There is a setting on the Advanced tab.



    Lennart
     
    Mark_01 likes this.
  46. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Loading the baked vegetation from a persistent storage is faster than doing the spawning run-time. For normal size terrains this could be a good option to do when all rules are complete. For large terrains you probably want to keep spawning run-time since the amount of instances easily could be in the multi millions and take up both disk space and memory.

    Lennart
     
  47. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    340
    I work with huge terrains and I spawn my foliage at runtime, but bigger are "rarer" objects are all baked. I also bake trees and billboards. This works very well!
     
  48. bok

    bok

    Joined:
    Feb 24, 2014
    Posts:
    44
    Is it possible to spawn prefabs with vegetation masks attached to them? For example if I want to randomly spawn a house and wherever that house spawns there should not spawn any grass or plants near that house. How could I achieve this?

    Also, can I spawn NPCs with the Vegetation Studio? And if so, can I spawn them only on certain terrain textures? For instance I want to spawn a Yeti, but only on snow terrain.
     
  49. rasto61

    rasto61

    Joined:
    Nov 1, 2015
    Posts:
    352
    http://awesometech.no

    https://www.awesometech.no/index.ph...onents/vegetation-masks/vegetation-mask-area/

    Just add a vegetation mask area to your prefabs and spawn. I believe that right now this only works if you are not using persistent storage.

    https://www.awesometech.no/index.php/runtime-prefab-spawner/


    If you want to spawn just npcs independent of vegetation but on specific texutes, just add 'dummy' vegetation of empty gameobjects with the texture rules you want and then use runtime prefab spawner to spawn the npcs around the dummy vegetation.
     
  50. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    340
    genius.
     
Thread Status:
Not open for further replies.