Search Unity

  1. 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

[Released] Vegetation Studio Pro

Discussion in 'Assets and Asset Store' started by LennartJohansen, Jun 29, 2018.

  1. RPowers

    RPowers

    Joined:
    May 14, 2015
    Posts:
    114
    Does grass work for URP v7.3.1? I'm trying it but all I see are pink shapes where the grass is trying to render.

    If URP is not currently supported is there an estimated time for when it will be? My project relies heavily on VS and I also need to convert to URP for performance reasons in VR. Thanks.
     
    Last edited: May 9, 2020
  2. SickaGamer

    SickaGamer

    Joined:
    Jan 15, 2018
    Posts:
    1,004
  3. JupiterOP

    JupiterOP

    Joined:
    Mar 5, 2019
    Posts:
    6
    I use entities to generate my terrain chunks. Is it possible to use Vegetation studio/pro for generating foliage where I tell it to, without any standard terrain gameobject?
     
  4. shebotnov

    shebotnov

    Joined:
    Jun 3, 2018
    Posts:
    20
    What does VS pro offers that the regular version doesnt? Is the following list ONLY for the PRO version?

    Code (CSharp):
    1. -Extensive Biome system
    2. -Supports both Unity terrains and mesh terrains
    3. -Rule based vegetation
    4. -Manual paining system
    5. -API for 3rd party tools and shaders
    6. -Run-time masking system
    7. -Instanced rendering
    8. -Rule based splat map generation
    9. -Touch bend grass and plants
    10. -Universal billboard system
    11. -Collider system
    12. -Real-time editor updates
    13. -Multiple terrains/cameras on a single Vegetation System
    14. -VR-Support
     
  5. Unplug

    Unplug

    Joined:
    Aug 23, 2014
    Posts:
    239
    who kidnapped Lennart ? he usually answer fast !
     
  6. Matthias1231

    Matthias1231

    Joined:
    Aug 20, 2012
    Posts:
    50
    Hi Lennart,

    I'm contemplating an upgrade to Pro and I was wondering if you ever managed to add the bitmap support for biomes?

    Thanks,
    Matthias
     
  7. rayD8

    rayD8

    Joined:
    Mar 7, 2018
    Posts:
    24
    Hello,
    Could you tell me why the Vegetation Item preview thumbnails would be missing on many of the items?
    However, they still work in the scene...
     
  8. AdminArdagor

    AdminArdagor

    Joined:
    Feb 6, 2018
    Posts:
    40
    Please tell me who knows if there is a script that allows you to convert Unity vegetation already planted on the Terrain into Vegetation Studio Pro vegetation, or at least change something in the Vegetation Studio Pro code so that I can use both types of vegetation in parallel (for Vegetation Studio Pro)?
     
  9. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,384
    Hi. Try to right click on the prefab and reimport. This is a unity issue with generating previews.

    Hi. There is no system for that. You will have to set up procedural rules to spawn the vegetation wih Vegetation Studio.

    Hi. The biome system is polygon based. You can not use bitmap data to define areas.

    Use the discord server for support requests. I only check the forums sometimes.

    Hi. Answered you on the discord server.

    Hi. If you join the discord server there is a channel where I post progress on the VSP 2020 version with SRP support.

    Lennart
     
  10. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,384
    Support request.

    Hi. Please use the discord server for support requests and questions. I do not check the forums often.
    Since most of my requests come in the discord serve I try to keep it there.

    Link in my sugnature.

    Lennart
     
  11. MlleBun

    MlleBun

    Joined:
    Sep 19, 2017
    Posts:
    114
    Hi,
    Sorry if this question has probably been asked, but does Vegetation Studio (Pro or not) only work with Unity's Terrain component ? Thanks !
     
  12. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,384
    Hi. Vegetation Studio Pro has support for using meshes as terrains. Have a look here.

    https://www.awesometech.no/index.php/mesh-terrain-pro/

    Lennart
     
  13. MlleBun

    MlleBun

    Joined:
    Sep 19, 2017
    Posts:
    114
    Hi, got almost the same issue.
    • Try to convert your custom mesh with MeshTerrainToolWindow you'll find under Windows -> Awesome Technologies.
    • On this new component,generate the Mesh TerrainData by clicking on Create MeshTerrainData object in the Mesh Terrain script component.
    • Then, all the others parameters on the VegetationSystemPro gameobjects seems ok in your screenshot.
    • Next, and that's when I thought it did not work, zoom very close to your terrain. The objects (your grass) might not show only because you are too far.
     
    newguy123 likes this.
  14. bok

    bok

    Joined:
    Feb 24, 2014
    Posts:
    42
    Hi Lennart,

    I'm using HDRP and keep getting many instances of this error:
    Shader properties can't be added to this global property sheet. Trying to add _GrabTexture_HDR (type 1 count 1)

    I've installed all required packages and Vegetation Studio Pro.
    Do you know how I can solve this?


    Also my AwesomeTechnology shaders are pink. Are there special HDRP shaders in Vegetation Studio Pro or is there something else that needs to be done to make the VS shaders work in HDRP?


    upload_2020-6-14_12-31-42.png
     
    Last edited: Jun 14, 2020
  15. gilley033

    gilley033

    Joined:
    Jul 10, 2012
    Posts:
    911
    Is there a method for setting multiple vegetation items to the same rule? Perhaps a biome wide rule set. For instance, I am trying to set most of my vegetation to not spawn on my terrain's mountains, so I'm using a Terrain Texture rule, which works. But it seems tedious to have to do this for each vegetation item, so I feel like I'm missing something. Thanks!
     
  16. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    286
    I have a problem with "area mask"

    1- I have a created area
    2- I want to modify some points of that area. (image "area_ini")
    3- When I move the cursor over it, without touching any point, the area moves "automatically", varying the location. (image 2 "area_fin", after passing the courses by scene view 15 times -so that it looks good-)
    4- When I move one of the "handles" all the vegetation in the area is automatically relocated, completely distorting its original situation. (image 3 "area_rdo")

    I look forward to your help or advice.

    Thank you.

    EDIT. More info

    a) I think the problem may be due to the areas being too large.
    b) with the option "show handles" deactivated, it does not happen.

    And I take this opportunity to ask a question.

    Is there a way to detect ("collision" style) that an object enters these areas without creating a collision zone?
    (It would be very useful)

    area_ini.png area_fin.png area_rdo.png
     
    Last edited: Jun 17, 2020
  17. Matthias1231

    Matthias1231

    Joined:
    Aug 20, 2012
    Posts:
    50
    Hi Lennart,

    I upgraded to Vegetation Studio Pro and am trying to integrate it into an existing open world system that streams many terrain objects of different sizes and resolutions from disk.

    In Vegetation Studio I assigned a VegetationSystem component to each terrain object.
    Then I used AddVegetationPackage() to add the same VegetationPackage to each.
    Finally I was able to assign different mask textures to each individual terrain object using VegetationSystem.UpdateLocalTextureMaskTexture().

    In Vegetation Studio Pro that seems no longer be possible and everything is managed globally with a single mask list shared between all terrains. I'm unable to make this work for my setup and at this point it seems like the only option might be to create a duplicate instance of each vegetation package for each terrain piece just so I can apply local terrain object masks.

    Is there any other way to do this? It's not feasible for me to rewrite the system to use the Vegetation Studio Pro management of multiple terrain objects, especially since mine are of various sizes.

    Thanks for any ideas,
    Matthias
     
  18. wumn

    wumn

    Joined:
    Jan 11, 2018
    Posts:
    25
    Hello, I have a question here that needs your help. I run the scene in edit mode and everything is normal. But when I build the project, it runs again. There will be a stuck frame rate. In the profiler window, you will find that there is a problem with the WaitForJobGroupID thread. Do you have any suggestions for me? I cut a picture for your reference.
     

    Attached Files:

  19. Matthias1231

    Matthias1231

    Joined:
    Aug 20, 2012
    Posts:
    50
    Lennart,

    FYI, there is a bug in VegetationPackagePro.cs line 735 in CopySettingValues(). It copies VegetationType twice but does not copy PrefabType.

    Edit:
    Ran into a number of other properties not being copied:
    DisableShadows
    Density
    RandomizePosition
    ScaleMultiplier
     
    Last edited: Jun 29, 2020
  20. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,394
    Hey Lennart, Is Cross Fade for the LODs placed with VS a possible option in the future? Know it is not as performant friendly but definitely more effective for higher poly trees that need to drop down quite a bit.

    Edit- Also know about primary support being on discord. Do not use discord so okay to wait for a response here as it is not critical.
     
  21. amit-chai

    amit-chai

    Joined:
    Jul 2, 2012
    Posts:
    61
    Hi! does vegetation studio pro supported with 2019.4?
     
    Barritico and fusion242 like this.
  22. lorddanger

    lorddanger

    Joined:
    Aug 8, 2015
    Posts:
    82
    Hello, does vegetation studio Pro supports URP?
     
    philwinkel likes this.
  23. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    286
    Works... but it has lost performance.
     
  24. MlleBun

    MlleBun

    Joined:
    Sep 19, 2017
    Posts:
    114
    Bug - Hi, just wanted to report an infinite Save Assets loop when you click on Apply Textures to terrain (Terrain System Pro script). I'm using 1.2.2. I was wondering why and how can I fix this issue ?

    upload_2020-7-13_10-52-6.png

    Also I can't tell you if it's linked, but I can see this warning in the console : upload_2020-7-13_10-55-56.png
     
    Last edited: Jul 13, 2020
  25. damir2076

    damir2076

    Joined:
    Feb 13, 2018
    Posts:
    4
    I have Vegetation studio and Vegetation studio Pro from Dec 2018. Several times tried to install VSPro without success.

    I tried with 2019.2.15f1 and 2019.3.15.f1.

    I always getting a lot of errors.
    upload_2020-7-20_2-5-39.png

    Jobs is part of Unity not package anymore, if I understand correctly.

    I changed api compatibility level, but I don't see Scripting Runtime Version
    upload_2020-7-20_2-7-38.png

    Does anybody know what is a problem?
     
  26. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    497
    Not sure. But double check that you have all of the packages that are required. Seems like something is missing.
    I had to follow the set up in steps provided and then it all worked.
    Check read me and/or website for full set up walkthrough. I think it is on their website, but I don't remember.
     
  27. Dark-Muppeteer

    Dark-Muppeteer

    Joined:
    Feb 24, 2013
    Posts:
    26
    Jobs is still in the package manager, you likely just need to go to the Advanced tab in the package manager window and select Show Preview Packages, so that it shows in the list.

    I think the Scripting Runtime Version just defaults to .Net4.xx under the hood in latest versions of Unity version so it shouldn't be an issue

    There's a few notes on the setup page about package versions, but just installing all the latest ones should be OK currently (unless you have a really old version of VSP). https://www.awesometech.no/index.php/setup-guide/
     
    dsilverthorn likes this.
  28. damir2076

    damir2076

    Joined:
    Feb 13, 2018
    Posts:
    4
    Tnx, it is working. Finally I install VS Pro, CTS 2019, RAM 2019 and Forest Environment HDRP without errors :)

    But Forest VS Biomes dont work.

    It is really great asset. I will try to make scene from blank.
     
    Dark-Muppeteer likes this.
  29. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    1,458
    All you need to install is Entities. The rest is installed implicitly via dependencies.
     
  30. combatsheep

    combatsheep

    Joined:
    Jan 30, 2015
    Posts:
    116
    Hi.

    I don't want the LightProbe to affect the billboard of VegetationStudio Pro.
    Is it possible to turn it off like the inspector of Mesh Renderer with VegetationStudio Pro?

    BillBoards_LightProbe.jpg MeshRenderer.jpg

    Thanks.
     
  31. Sackwut

    Sackwut

    Joined:
    Nov 13, 2018
    Posts:
    5
    Hi, i have already asked a question in the R.A.M. hread, because i have an issue with the River as it cracks in artifacts.
    I found out, that this is because of the biomes is use with vegetation studio pro. As soon as i deactive the Biome/GO, the river shows clearly.
    Using Unity 2019.2.21f1

    Thanks in advance

    Edit 11.08.2020
    With help of another user on discord, we found a solution for this behaviour. Alot of prefabs were set to Instanced Inderect on the Biome General Render Setting. This caused the issue!
    I needed to change all prefabrs in the biome to Instanced and now everything is working fine.

    Regards
     

    Attached Files:

    Last edited: Aug 11, 2020
  32. TimeSniper

    TimeSniper

    Joined:
    Nov 26, 2012
    Posts:
    18
    I have great help from the terrain texture masking feature. It speeds up the process so much. I love it. But it seems like there is no for meshes. At this moment, not to see the plants and trees on such as rock, road, bridge meshes, I have only an option to paint textures under them and set the textures as exclude terrain mask, which is very annoying and time consuming.
    Do you have this feature already and am I missing it? If not, do you have a plan to add this feature, masking according to mesh or layer, tag?
     
    Last edited: Aug 15, 2020
  33. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    379
    I was always thinking that VS pro is supporting HDRP, now I have seen some posts that it is not.
    So what is the actual truth?
     
  34. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    465
    How does this interact with / compare to Gaia Pro? Im assuming this is going to be the more performant vegetation system?

    If theres a reason to use this with Gaia, what would the recommended workflow be? Create the terrain with Gaia and then populate the vegetation with this? I know Gaia has its own rule set for biomes ... would this entirely replace that system outside of generating the terrain itself, and I guess whatever terrain shader I use (CTS I guess)?

    Theres so many different things out there Im having a hard time wrapping my head around the best looking - most performant - easiest to use combination.

    Thanks!
     
  35. jimmygladfelter

    jimmygladfelter

    Joined:
    May 3, 2020
    Posts:
    39
    I am using MapMagic to create infinite world streaming system with VSPro and my technique right now is to create a clone of a 'source' system when a new terrain is loaded. I cannot use persistent storage because MapMagic basically generates texture masks for where the vegetation will go when terrain is loaded into view. I saw that one performance hit I was getting was the constant re initializing of VegetationPackageProModelInfo. Since multiple terrains span the same biome, I created a cache to manage this. It will cache all vegetation models for all packages referenced in the scene on startup of the game so it doesn't have to reinit any when new terrains are loaded. I did this by adding the following code:

    In VegetationSystemPro.cs, I added:
    Code (CSharp):
    1. // reference to the model cache being used, if one is.
    2.         public VegetationSystemPro_ModelCache ModelCache;
    3.  
    4. /// <summary>
    5.         /// Creates a cache of all models of all packages from all existing Vegetation Studio systems and uses it to make new models
    6.         /// when setting up/refreshing vegetation. If a model does not happen to be in the cache when the system is created,
    7.         /// it will create a new one and add it to the cache.
    8.         /// </summary>
    9.         public void EnableCacheModels ( bool refreshVegetationSystem ) {
    10.             if ( this.ModelCache == null ) {
    11.                 this.ModelCache = GameObject.FindObjectOfType<VegetationSystemPro_ModelCache>();
    12.                 if ( this.ModelCache == null ) {
    13.                     // create a model cache
    14.                     VegetationStudioManager manager = VegetationStudioManager.Instance;
    15.                     GameObject managerGo = manager != null ? manager.gameObject : null;
    16.                     if ( managerGo != null ) {
    17.                         this.ModelCache = managerGo.AddComponent<VegetationSystemPro_ModelCache>();
    18.                     }
    19.                 }
    20.                 if ( this.ModelCache != null ) {
    21.                     this.ModelCache.AddCachingSystem(this);
    22.                     if ( refreshVegetationSystem ) {
    23.                         this.RefreshVegetationSystem();
    24.                     }
    25.                 }
    26.             }
    27.         }
    28.         /// <summary>
    29.         /// Disables the use of cached models for this system.
    30.         /// </summary>
    31.         public void DisableCacheModels ( bool refreshVegetationSystem ) {
    32.             if ( this.ModelCache != null ) {
    33.                 this.ModelCache.RemoveCachingSystem(this);
    34.                 this.ModelCache = null;
    35.                 if ( refreshVegetationSystem ) {
    36.                     this.RefreshVegetationSystem();
    37.                 }
    38.             }
    39.         }
    40.  
    41. void OnDisable () {
    42.             //...
    43.             DisableCacheModels(false);
    44.             //...
    45. }
    In VegetationSystemPro_Models.cs, I altered the 'SetupVegetationItemModels ' method:
    Code (CSharp):
    1. public void SetupVegetationItemModels () {
    2.             List<GameObject> windSamplerList = new List<GameObject>();
    3.             for ( int i = 0; i <= VegetationStudioCameraList.Count - 1; i++ ) {
    4.                 windSamplerList.Add(VegetationStudioCameraList[i].WindSampler);
    5.             }
    6.  
    7.             ClearVegetationItemModels();
    8.  
    9.             float additonalBoundingSphereRadius = 0;
    10.             int cameraCount = VegetationStudioCameraList.Count;
    11.             for ( int i = 0; i <= VegetationPackageProList.Count - 1; i++ ) {
    12.                 // if we have a model cache setup, create a clone of the model info to use instead of creating a new one.
    13.                 VegetationPackageProModelInfo vegetationPackageProModelInfo = this.ModelCache != null ? this.ModelCache.makeClone(VegetationPackageProList[i], EnvironmentSettings, windSamplerList, cameraCount) : null;
    14.                 if ( vegetationPackageProModelInfo == null ) {
    15.                     vegetationPackageProModelInfo = new VegetationPackageProModelInfo(VegetationPackageProList[i], EnvironmentSettings, windSamplerList, cameraCount);
    16.                 }
    17.  
    18.                 VegetationPackageProModelsList.Add(vegetationPackageProModelInfo);
    19.  
    20.                 additonalBoundingSphereRadius = Mathf.Max(additonalBoundingSphereRadius,
    21.                     vegetationPackageProModelInfo.GetAdditionalBoundingSphereRadius());
    22.             }
    23.             AdditionalBoundingSphereRadius = additonalBoundingSphereRadius;
    24.         }
    In VegetationPackageProModelInfo.cs, I added a copy constructor:
    Code (CSharp):
    1. /// <summary>
    2.         /// Copy Constructor used to limit reloading the same models when multiple (cloned) systems are used.
    3.         /// </summary>
    4.         /// <param name="infoToClone"></param>
    5.         /// <param name="environmentSettings"></param>
    6.         /// <param name="windSamplerList"></param>
    7.         /// <param name="cameraCount"></param>
    8.         public VegetationPackageProModelInfo ( VegetationPackageProModelInfo infoToClone, EnvironmentSettings environmentSettings, List<GameObject> windSamplerList, int cameraCount ) {
    9.             EnvironmentSettings = environmentSettings;
    10.  
    11.             List<VegetationItemModelInfo> modelListToClone = infoToClone.VegetationItemModelList;
    12.             if ( modelListToClone != null ) {
    13.                 foreach ( VegetationItemModelInfo modelToClone in modelListToClone ) {
    14.                     if ( modelToClone != null ) {
    15.                         VegetationItemModelInfo vegetationItemModelInfo =
    16.                             new VegetationItemModelInfo(modelToClone, EnvironmentSettings, windSamplerList, cameraCount);
    17.                         VegetationItemModelList.Add(vegetationItemModelInfo);
    18.                     }
    19.                 }
    20.             }
    21.         }
    In VegetationItemModelInfo.cs, I also added a copy construtor:
    Code (CSharp):
    1. /// <summary>
    2.         /// Copy Constructor used to limit reloading the same models when multiple systems are used.
    3.         /// </summary>
    4.         /// <param name="infoToClone"></param>
    5.         /// <param name="environmentSettings"></param>
    6.         /// <param name="windSamplerList"></param>
    7.         /// <param name="cameraCount"></param>
    8.         public VegetationItemModelInfo ( VegetationItemModelInfo infoToClone, EnvironmentSettings environmentSettings, List<GameObject> windSamplerList, int cameraCount ) {
    9.             EnvironmentSettings = environmentSettings;
    10.  
    11.             VegetationItemInfo = infoToClone.VegetationItemInfo;
    12.             VegetationModel = infoToClone.VegetationModel;
    13.  
    14.             DistanceBand = infoToClone.DistanceBand;
    15.  
    16.             SelectedVegetationModelLOD0 = infoToClone.SelectedVegetationModelLOD0;
    17.             SelectedVegetationModelLOD1 = infoToClone.SelectedVegetationModelLOD1;
    18.             SelectedVegetationModelLOD2 = infoToClone.SelectedVegetationModelLOD2;
    19.             SelectedVegetationModelLOD3 = infoToClone.SelectedVegetationModelLOD3;
    20.  
    21.             ShaderControler = infoToClone.ShaderControler;
    22.             LODCount = infoToClone.LODCount;
    23.  
    24.             CreateCameraWindSamplerItems(windSamplerList);
    25.  
    26.             LODFadePercentage = infoToClone.LODFadePercentage;
    27.             LODFadeCrossfade = infoToClone.LODFadeCrossfade;
    28.  
    29.             VegetationMeshLod0 = infoToClone.VegetationMeshLod0;
    30.             VegetationMeshLod1 = infoToClone.VegetationMeshLod1;
    31.             VegetationMeshLod2 = infoToClone.VegetationMeshLod2;
    32.             VegetationMeshLod3 = infoToClone.VegetationMeshLod3;
    33.  
    34.             VegetationRendererLOD0 = infoToClone.VegetationRendererLOD0;
    35.             VegetationMaterialsLOD0 = cloneMaterialArray(infoToClone.VegetationMaterialsLOD0);
    36.  
    37.             VegetationRendererLOD1 = infoToClone.VegetationRendererLOD1;
    38.             VegetationMaterialsLOD1 = cloneMaterialArray(infoToClone.VegetationMaterialsLOD1);
    39.  
    40.             VegetationRendererLOD2 = infoToClone.VegetationRendererLOD2;
    41.             VegetationMaterialsLOD2 = cloneMaterialArray(infoToClone.VegetationMaterialsLOD2);
    42.  
    43.             VegetationRendererLOD3 = infoToClone.VegetationRendererLOD3;
    44.             VegetationMaterialsLOD3 = cloneMaterialArray(infoToClone.VegetationMaterialsLOD3);
    45.  
    46.             VegetationMaterialPropertyBlockLOD0 = infoToClone.VegetationMaterialPropertyBlockLOD0;
    47.             VegetationMaterialPropertyBlockLOD1 = infoToClone.VegetationMaterialPropertyBlockLOD1;
    48.             VegetationMaterialPropertyBlockLOD2 = infoToClone.VegetationMaterialPropertyBlockLOD2;
    49.             VegetationMaterialPropertyBlockLOD3 = infoToClone.VegetationMaterialPropertyBlockLOD3;
    50.             VegetationMaterialPropertyBlockShadowsLOD0 = infoToClone.VegetationMaterialPropertyBlockShadowsLOD0;
    51.             VegetationMaterialPropertyBlockShadowsLOD1 = infoToClone.VegetationMaterialPropertyBlockShadowsLOD1;
    52.             VegetationMaterialPropertyBlockShadowsLOD2 = infoToClone.VegetationMaterialPropertyBlockShadowsLOD2;
    53.             VegetationMaterialPropertyBlockShadowsLOD3 = infoToClone.VegetationMaterialPropertyBlockShadowsLOD3;
    54.  
    55.             LOD1Distance = infoToClone.LOD1Distance;
    56.             LOD2Distance = infoToClone.LOD2Distance;
    57.             LOD3Distance = infoToClone.LOD3Distance;
    58.  
    59.             BoundingSphereRadius = infoToClone.BoundingSphereRadius;
    60.  
    61.             CreateCameraBuffers(cameraCount);
    62.  
    63.             HeightRuleCurveArray = new NativeArray<float>(4096, Allocator.Persistent);
    64.             UpdateHeightRuleCurve();
    65.  
    66.             SteepnessRuleCurveArray = new NativeArray<float>(4096, Allocator.Persistent);
    67.             UpdateSteepnessRuleCurve();
    68.  
    69.             BillboardMaterial = infoToClone.BillboardMaterial;
    70.         }
    71.  
    72.         protected static Material[] cloneMaterialArray ( Material[] toCopy ) {
    73.             int toCopyLength = toCopy != null ? toCopy.Length : 0;
    74.             Material[] clonedArray = new Material[toCopyLength];
    75.             for ( int i = 0; i < toCopyLength; i++ ) {
    76.                 clonedArray[i] = new Material(toCopy[i]);
    77.             }
    78.             return clonedArray;
    79.         }
    Finally, here is my code the cache itself. It gets added to the vegetation studio manager script's game object and gets removed when its not being used:
    Code (CSharp):
    1. using AwesomeTechnologies.VegetationStudio;
    2. using AwesomeTechnologies.VegetationSystem;
    3. using System;
    4. using System.Collections;
    5. using System.Collections.Generic;
    6. using UnityEngine;
    7.  
    8. /// <summary>
    9. /// Represents cached models of all models of all packages of all Vegetation Studio Pro systems.
    10. /// Primarily used when there are multiple systems (maybe a source system is copied to each terrain loaded in an infinite world streamer).
    11. /// </summary>
    12. public class VegetationSystemPro_ModelCache : MonoBehaviour, IDisposable {
    13.  
    14.     // create an object to hold the model info to clone.
    15.     protected Dictionary<string, VegetationPackageProModelInfo> cloneablePackageModelInfoByPackageNameMap;
    16.  
    17.     // keep track of the systems using cached models.
    18.     protected HashSet<VegetationSystemPro> systemsUsingCachedModels;
    19.  
    20.  
    21.     void Start () {
    22.         // populate the cache
    23.         this.PopulateModelCache();
    24.     }
    25.  
    26.     /// <summary>
    27.     /// Adds a reference to the caching system.
    28.     /// </summary>
    29.     /// <param name="system"></param>
    30.     public void AddCachingSystem ( VegetationSystemPro system ) {
    31.         if ( system != null ) {
    32.             if ( this.systemsUsingCachedModels == null ) {
    33.                 this.systemsUsingCachedModels = new HashSet<VegetationSystemPro>();
    34.             }
    35.             this.systemsUsingCachedModels.Add(system);
    36.         }
    37.     }
    38.  
    39.     /// <summary>
    40.     /// Removes a reference to a system that might have once used caching.
    41.     /// If there are no more cached systems, remove this component as we dont need it anymore.
    42.     /// </summary>
    43.     /// <param name="system"></param>
    44.     public void RemoveCachingSystem ( VegetationSystemPro system ) {
    45.         if ( system != null && this.systemsUsingCachedModels != null ) {
    46.             this.systemsUsingCachedModels.Remove(system);
    47.             if ( this.systemsUsingCachedModels.Count <= 0 ) {
    48.                 this.Dispose();
    49.                 GameObject.DestroyImmediate(this);
    50.             }
    51.         }
    52.     }
    53.  
    54.     /// <summary>
    55.     /// Finds all existing vegetation systems and populates the cache with all the models from all referenced packages in each system.
    56.     /// </summary>
    57.     public void PopulateModelCache () {
    58.         if ( VegetationStudioManager.Instance != null ) {
    59.             // find all existing systems.
    60.             List<VegetationSystemPro> allExistingVegetationSystems = VegetationStudioManager.Instance.VegetationSystemList;
    61.             if ( allExistingVegetationSystems != null ) {
    62.                 foreach ( VegetationSystemPro existingSystem in allExistingVegetationSystems ) {
    63.                     if ( existingSystem != null ) {
    64.                         // iterate over the package list and populate cache with cloneable models.
    65.                         List<VegetationPackagePro> packageList = existingSystem.VegetationPackageProList;
    66.                         if ( packageList != null ) {
    67.                             foreach ( VegetationPackagePro package in packageList ) {
    68.                                 if ( package != null ) {
    69.                                     string packageName = package.PackageName;
    70.  
    71.                                     // see if we already made a clone of this item.
    72.                                     VegetationPackageProModelInfo vegetationPackageProModelInfo = null;
    73.                                     if ( this.cloneablePackageModelInfoByPackageNameMap != null ) {
    74.                                         this.cloneablePackageModelInfoByPackageNameMap.TryGetValue(packageName, out vegetationPackageProModelInfo);
    75.                                     }
    76.  
    77.                                     if ( vegetationPackageProModelInfo == null ) {
    78.                                         // need a cloneable model, so create and add one.
    79.                                         this.setCloneableModelInfo(packageName, new VegetationPackageProModelInfo(package, existingSystem.EnvironmentSettings, new List<GameObject>(), 0));
    80.                                     }
    81.                                 }
    82.                             }
    83.                         }
    84.                     }
    85.                 }
    86.             }
    87.         }
    88.     }
    89.  
    90.     /// <summary>
    91.     /// Use the cached models to make a clone of the cached models to use when setting up vegetation.
    92.     /// </summary>
    93.     /// <param name="package"></param>
    94.     /// <param name="environmentSettings"></param>
    95.     /// <param name="windSamplerList"></param>
    96.     /// <param name="cameraCount"></param>
    97.     /// <returns></returns>
    98.     public VegetationPackageProModelInfo makeClone ( VegetationPackagePro package, EnvironmentSettings environmentSettings, List<GameObject> windSamplerList, int cameraCount ) {
    99.         if ( package == null ) {
    100.             return null;
    101.         }
    102.         string packageName = package.PackageName;
    103.         VegetationPackageProModelInfo vegetationPackageProModelInfo = null;
    104.         if ( this.cloneablePackageModelInfoByPackageNameMap != null ) {
    105.             this.cloneablePackageModelInfoByPackageNameMap.TryGetValue(packageName, out vegetationPackageProModelInfo);
    106.         }
    107.         if ( vegetationPackageProModelInfo != null ) {
    108.             // clone it
    109.             vegetationPackageProModelInfo = new VegetationPackageProModelInfo(vegetationPackageProModelInfo, environmentSettings, windSamplerList, cameraCount);
    110.         } else {
    111.             // create a new one and cache a clone of it for later.
    112.             vegetationPackageProModelInfo = new VegetationPackageProModelInfo(package, environmentSettings, windSamplerList, cameraCount);
    113.             this.setCloneableModelInfo(packageName, new VegetationPackageProModelInfo(vegetationPackageProModelInfo, environmentSettings, windSamplerList, cameraCount));
    114.         }
    115.         return vegetationPackageProModelInfo;
    116.     }
    117.  
    118.     /// <summary>
    119.     /// Helper method to set a cloneable model into the cache.
    120.     /// </summary>
    121.     /// <param name="packageName"></param>
    122.     /// <param name="vegetationPackageProModelInfo"></param>
    123.     protected void setCloneableModelInfo ( String packageName, VegetationPackageProModelInfo vegetationPackageProModelInfo ) {
    124.         if ( packageName != null && vegetationPackageProModelInfo != null ) {
    125.             if ( this.cloneablePackageModelInfoByPackageNameMap == null ) {
    126.                 this.cloneablePackageModelInfoByPackageNameMap = new Dictionary<string, VegetationPackageProModelInfo>();
    127.             }
    128.             this.cloneablePackageModelInfoByPackageNameMap.Add(packageName, vegetationPackageProModelInfo);
    129.         }
    130.     }
    131.  
    132.     void OnDisable () {
    133.         this.Dispose();
    134.     }
    135.  
    136.     public void Dispose () {
    137.         if ( this.cloneablePackageModelInfoByPackageNameMap != null ) {
    138.             foreach ( KeyValuePair<string, VegetationPackageProModelInfo> entry in this.cloneablePackageModelInfoByPackageNameMap ) {
    139.                 VegetationPackageProModelInfo cloneableModelInfo = entry.Value;
    140.                 if ( cloneableModelInfo != null ) {
    141.                     cloneableModelInfo.Dispose();
    142.                 }
    143.             }
    144.             this.cloneablePackageModelInfoByPackageNameMap = null;
    145.         }
    146.     }
    147. }
    148.  


    Directions to use
    ---------------------
    When I copy the source vegetation studio pro system to a loaded terrain, I call system.EnableCacheModels() and it will cache all models from all packages in all vspro systems in the scene and instantiate a copy of the model when setting up vegetation for copied systems.

    What do you think @Lennart?
    Is this a feature you could possibly add in a future update?
     
    Last edited: Aug 25, 2020
    ko0zi likes this.
  36. jimmygladfelter

    jimmygladfelter

    Joined:
    May 3, 2020
    Posts:
    39
    Here's a video demonstrating my above solution with MapMagic: It will cache all vegetation models for all packages referenced in the scene on startup of the game so it doesn't have to reinit any when new terrains are loaded.


    With optimized vegetation, it virtually gets rid of most lag when creating new terrains. FPS was also +10 when I wasnt recording my screen with Bandicam.

    I hope Lennart can maybe implement these changes as a nice solution for large world streaming systems that have lots of in-common models across terrains when using mutliple systems.
     
    Last edited: Aug 25, 2020
  37. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,384
    combatsheep likes this.
  38. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    511
    Will Unity 2020 be supported?
     
unityunity