Search Unity

  1. Unity 2020.1 has been released.
    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

[RELEASED] Vegetation Studio

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

  1. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,380
    The pool is next on my list now. I will try to get it in the next update.

    I did not set the price for Vegetation Studio Pro yet but the upgrade price will be the difference between standard and pro with an additonal discount at release time.

    Lennart
     
    Pecek likes this.
  2. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    818
    Hi, I find the vegetation system's update method is consuming several ms in the profiler:
    upload_2018-8-13_11-24-12.png
    For I'm using an older version of VS, don't know if this is optimized in the 1.4.0.0 version?
    Or how can I optimize this update?
     
  3. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
    @LennartJohansen Hi there, I've recently learned that you are now focusing mesh terrain support in Vegetation Studio Pro, do you have an ETA for this and for a Pro version could you please test Voxeland compatibility thank you.
     
  4. PVincenti

    PVincenti

    Joined:
    Jul 17, 2018
    Posts:
    8
    Hi,
    First of all I want to say that this asset is really impressive. But I am running into an issue where I need to export the output of a camera to a render texture. When I do, the vegetation is gone from the render. Is there a solution to this?

    Thank
     
  5. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,380
    Hi. I answered a post about this on the Vegetation Studio Pro forum today. You can find it here.
    The Vegetation Studio Pro beta is available now. Vegetation Studio users can sign up on the website for access.

    https://www.awesometech.no/index.php/vegetation-studio-pro-signup/

    Lennart
     
  6. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,380
    Hi. If you assign a camera with a render texture output to the VegetationSystem component it should work as normal.
    For rendering manually with Camera.Render you need to make sure that this is called after the VegetationSystem and BillboardSystem components has processed in the frame. Adjust the Script Execution Order on your render script to be after the components and try to render in LateUpdate.

    Send me a message if it does not work.

    Lennart
     
    PVincenti likes this.
  7. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,380
    Hi. Is this profile from a build or editor?

    There is no big changes to the render loop that will affect this in 1.4.0.0

    Only change that could affect it is a mode for shadow culling that will render all shadows from trees behind the camera without frustum tests. This could save some CPU time at the cost of rendering some extra shadows.

    The ExecureRenderVegetation call is doing all the preparation of render lists, frustum and shadow culling on trees (and optionally objects and large objects) and LOD selection before doing the actual rendering.

    The only big way to reduce this is making sure as much as the vegetation as possible render instanced indirect. Less to process on the CPU and faster drawcalls.

    This code is faster on a build and it should help additionally to use IL2CPP for your builds.

    Lennart
     
  8. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    818
    Thanks for the reply!
    This profiler is from editor, I'll try to modify the speedtree shader to render all trees by instanced indirect, all speedtree shaders can be rendered in this method, right?
    And any optimizations on this part in VS pro? I read that you said more calculations are thrown into GPU and multithreads.
     
  9. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    818
    I met an issue with cell rendering with persistent database.
    All my vegetation location data is in persistent database.
    But some cells does not render model trees/large objects, it looks like this:


    But all the grass and small objects are fine, seems related to billboard rendering. Also, this does not happen for all cells, some area on the terrain the trees can be rendered correctly.
    Is this a known issue and fixed in the latest version? For I'm still using version 1.1.2.0.
    Thanks for your time :)
     
  10. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,380
    There might be a bug here somewhere. I think it is related to the "Exclude sea level cells" setting on the Vegetation System component. I will have a look at this.

    Trees does not render instanced indirect yet, but I am working on that. Need to do shadow culling on the GPU.

    Yes. In Vegetation Studio Pro all this is done in Burst compiled jobs. Really good speedup compared to doing this in c#

    Lennart
     
    Harekelas likes this.
  11. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    818
    Does VS Pro only support unity 2018.2+ ?
     
  12. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,380
    Yes. That is currently the minimum Unity version to use the Burst compiler and Collections. I expect that to change to 2018.3 before release.

    Lennart
     
  13. PVincenti

    PVincenti

    Joined:
    Jul 17, 2018
    Posts:
    8
    Sorry I completely missed the notification from your reply, I ended up working around the issue but I will let you know if I ever get to try it!
     
  14. PVincenti

    PVincenti

    Joined:
    Jul 17, 2018
    Posts:
    8
    Hi again,

    I have an insanely specific issue I'm dealing with that just feels like black magic to me.
    So essentially I'm using VS to populate a VR environment. The wind is working fine in my speedtrees if I just plop them in my VR scene or if I integrate them as terrain trees. It also works fine with VS in a non-VR scene. But in my VR scene, with VS, it doesn't work, but it starts working by changing around the target camera a few times. Other objects affected set as VS trees are affected by the wind, but not my speedtrees. Is there any chance there is an easy fix for that?

    Thank you!
     
  15. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,785
    26 pages later... did you(s) ever get the 5.6 integration with EasyRoads3D done sir? would be nice to remove the grass from my paths..
     
  16. DevS0L0

    DevS0L0

    Joined:
    Feb 10, 2017
    Posts:
    12
    Would be much quicker to just use the Vegetation Mask Line component. My 8X8K Terrain took about an hour doing it manually.

    Does anybody here face a bug with UBER shader's specular settings? It seems every time i enable specular, it is much darker in the Vegetation System opposed to the mesh placed in the Hierarchy. Loading the shader via script, and or replacing the "StandardShader" in VTS does not appear to do anything. Weather effects seem to work and everything else except for any sort of specular color or power.
     
    Last edited: Aug 19, 2018
  17. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,194
    Hello,

    I made a small Project including vegetatation Studio using microsplat and enviro.

    PC Standalone build runs very good. When deploying to Android with Standard Settings, there is no gras. I can see the landscape, just without gras. And the Performance is extremly bad.

    Any idea why gras is missing on Android and why the bad Performance there?

    Thanks a lot and have a nice Weekend :)
     
  18. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,380
    Hi. Vegetation Studio requires Shader Model 5.0 to run properly. It uses Compute Shaders, and instanced indirect for rendering. Most mobile platforms does not support this. You might be able to get it running if you switch rendering to instanced and disable compute shaders. That should lower the requirements to Shader Model 4.5

    Instancing is ideal on higher end graphics hardware and scenes where you have a lot of grass and plant instanced. Where you lower overhead with drawning the same mesh/material several time at different locations.

    For mobile platforms you would have to scale down the amount a lot since you have less GPU power and the benefits of instancing would be much less since you have less instances to render.

    Send me a pm with some more info about your android device and I can help you debug a bit.

    Lennart
     
  19. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,380
    EasyRoads3D does have integration with Vegetation Studio now. You can enable a setting to automatic create VegetationMaskLines for the roads when creating them.

    Lennart
     
    twobob likes this.
  20. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,380
    Hi. I have an idea what it could be. Speedtree wind is a bit tricky to sample. Speedtrees has an hidden "tree" component that calculates a long list of wind parameters that is different for each tree type. In order to sample this wind settings for use with instanced rendering this component has to be rendered and visible.

    Vegetation Studio has a wind sampler system that keeps an empty GameObject with this tree component visible.

    When using VR unity moves the camera to the tracked position just before rendering to keep latency down. My guess is that it actually moves the camera to not see the wind sampler, but I think we can fix this.

    Do you mind joining the Discord server and send me a message. Better to debug with a text chat.

    Lennart
     
    PVincenti likes this.
  21. sunseeker1988

    sunseeker1988

    Joined:
    Jul 10, 2014
    Posts:
    451
    Hi, I have an issue thats kind of weird. I have added trees into vegetation studio and some plants. When I zoom in the editor the trees leafes are added back into the game window but highlighted blue and the vegetation dissipears from teh ground. When I zoom in the leafes are removed and I hjave bare trunks and all the ground foliage is added back in. I cannot figure out how to have the trees keep their leafs. when I play the game every tree is bare.
     
  22. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,785
    I must be completely blind.
    http://unityterraintools.com/EasyRoads3D/v3/html/terrain_control.html
    I cannot find any reference to it other than the one script that has to be elided to make Roads3D run these days.
    I've asked anyway https://forum.unity.com/threads/eas...-new-road-system.229327/page-109#post-3602359 thanks again for your time.
     
  23. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,785
    That sounds like a submesh being linked with Instanced Indirect where infact all your leaves are being drawn to "some place" and only the trunks respect placement - you should probably see weird shadows too at certain angles.

    The fix is to use trees that are VS ready - i.e. a single mesh. One can also try adjusting the types of rendering for the trees to Instanced to see if that helps.

    This is all a total guess based on the last time I did that. Hope it helps
     
    sunseeker1988 likes this.
  24. PVincenti

    PVincenti

    Joined:
    Jul 17, 2018
    Posts:
    8

    That is awesome! I would be glad to join the discord tomorrow. I never used it before so sorry if this is a newbie question, but is there any sort of credentials needed in order to access the server?
     
  25. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,380
    Just make a user. The link is in my signature and on the description on asset store
     
  26. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    912
    Hi @LennartJohansen, has VS change to require textures now? It brings a warning to match terrain texture number of terrain when I usually select 0. I have map magic doing the terrain textures with RTP and it seem to be causing an error with one of my textures covering the whole map when i select 4 to match terrain.

    Also how long does the sign up for pro beta usually take as I applied last week and have new project in 2018 which id like to test while leaving my old one on the standard version.

    Andy
     
  27. LennartJohansen

    LennartJohansen

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

    What do you do when you get the warning? Should be no requirement.
    Could you send me a pm with the username on the website for beta access. I approve users every day. You should have got access a week ago if you signed up then

    Lennart
     
  28. AlexVipz

    AlexVipz

    Joined:
    May 12, 2017
    Posts:
    8
    Hello. I have a question, why using VS's spawning system for spawning trees my mineable tree script doesnt work? Dragging my tree into scene with the script attached to it works like a charm but with VS doesnt at all. Am I missing something?
     
  29. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,380
    Hi. Vegetation Studio does not use GameObjects for rendering vegetation. All trees, rocks and grass are just instances in memory that is loaded and culled before rendered with the new instancing APIs. This is much faster than working with gameobjects. You can not add scripts to trees the normal way but there is way to do this.

    Find the tree on the vegetation tab and enable a collider. Set the size until it fits the tree trunk good.

    with colliders enabled the collider system component will spawn colliders for the trees that are close to the camera.

    Then make a script that connects to the OnCreateCollider event of the collider system.
    Have a look here for more info.

    In this event you can access the colliders gameobject and add your mining script to this.
    If you want to remove the tree completely you can add a VegetationItemMask component to the scene.

    Have a look at the harvesting script in the downloadable demo scene.

    Lennart
     
  30. AlexVipz

    AlexVipz

    Joined:
    May 12, 2017
    Posts:
    8
    How to add my mining script there? I am pretty confused.
     
  31. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,155
    You want to use the callback OnCreateCollider. Create a script and make a function MyFunction and do VegetationStudio.ColliderSystem.OnCreateCollider += MyFunction; (or whatever the script order is) Then whenever a collider is generated by VS is will send the collider to that callback function you specified. Then you can have a look at .. actually I have an old script here somewhere..

    Code (CSharp):
    1.     void OnCreateCollider(Collider collider) {
    2.         AwesomeTechnologies.Vegetation.RuntimeObjectInfo info = collider.GetComponent<AwesomeTechnologies.Vegetation.RuntimeObjectInfo>();
    3.         if (info != null) {
    4.             if (info.VegetationItemInfo.Name.Contains("Ore")) {
    5.                 collider.gameObject.AddComponent<HarvestableOre>();
    6.             }
    7.             else if (info.VegetationItemInfo.Name.Contains("Stone")) {
    8.                 collider.gameObject.AddComponent<HarvestableRock>();
    9.             }
    10.             else if (info.VegetationItemInfo.Name.Contains("Cannabis")) {
    11.                 collider.gameObject.AddComponent<HarvestableTextile>();
    12.             }
    13.             else if (info.VegetationItemInfo.VegetationType == AwesomeTechnologies.VegetationType.Tree) {
    14.                 collider.gameObject.AddComponent<HarvestableTree>();
    15.             }
    16.         }
    17.         collider.gameObject.layer = GlobalMasks.resourcesLayer;
    18.     }
    something like that. Prefer not to use GetComponent really... I thought I improved this somewhere but I don't see it =D
     
  32. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,634
    be sure to look at his demo as well, it will show a bit of what Malkere is talking about. I suggest to look for it in VS. Its called VS harvesting, demo or something. Look for the scripts for it. You may need to download it from the VS site. actually I believe you do.
     
  33. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,634

    You can use a tree plant with sub meshes, you would need to search for Lennarts old post on this. Its a little picky about how this is done. its not to bad though, I had to change some of mine as well to get them to work. I just moved some of my parts a child.basically so I had sub meshes. as my game I can't use just one mesh... for our trees plants, as they split into more than one in run time. So. this can be done.
     
  34. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,634

    I tested VS a lot for Android, and sadly, you won't be able to use for low end Androids.. VS is a bit to heavy.. for it..Now for higher end, it works fine, just be sure to lower your shader level to around 4.5 ish I think, and disabled compute. Android don't support compute shaders.. I wish VS supported Android lower end , but its not that great for it. due to how it was built. Its awesome for PC, and console though...and very high end tablets and phones. I tested this extensive... I use for PC and console, but personally removed it for mobile. I hated to do it... Only way around it as do what I suggest and your going to have to use very low density , vegetation... and don't support low end Androids.... That is it. if you use VS.. for Android..
     
  35. AlexVipz

    AlexVipz

    Joined:
    May 12, 2017
    Posts:
    8
    Ugh.. still confused.. looked over both demo and your code, wrote this:
    public class Harvesting : MonoBehaviour {
    void OnCreateCollider(Collider collider)
    {
    AwesomeTechnologies.Vegetation.RuntimeObjectInfo info = collider.GetComponent<AwesomeTechnologies.Vegetation.RuntimeObjectInfo>();
    if (info.VegetationItemInfo.VegetationType == AwesomeTechnologies.VegetationType.Tree)
    {
    collider.gameObject.AddComponent<MineableObject>();
    }
    }
    }
    Now what? Where do I have to attach this script?
     
  36. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,380
    In his example MineableObject is the script that is added to the GameObject of the collider.
    That you would replace with your script. You can also modify settings on the script as you would any normal script

    Code (csharp):
    1.  
    2. collider.gameObject.AddComponent<MineableObject>();
    3.  
    This is where the script is added.

    Lennart
     
  37. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,155
    You need to have a script somewhere in your scene that is always there, always running, and only one. Probably easiest to just put it on your VegetationStudio prefab, or create a new empty GameObject and call it "VegetationHandler" or whatever. The script has to incorporate the callback OnCreateCollider. Basically, whenever VS adds a collider into the scene it will send out a message to anyone that asked to be informed. That's what the OnCreateCollider += MyFunction portion does, it tells the callback "let me know everytime you create a collider". So whenever VS does create a collider it will enact MyFunction. That's the function you need on ONE persistent script somewhere. Put the OnCreateCollider += MyFunction in the Awake() or Start() function, and put a Debug.Log("callback") in MyFuction to make sure it's working.
     
  38. JBT27

    JBT27

    Joined:
    Jul 13, 2016
    Posts:
    197
    When I click Generate terrain splat map, I'm getting this error:

    IndexOutOfRangeException: Array index is out of range.
    AwesomeTechnologies.TerrainSystem.GenerateTerrainSplatMap (Bounds bounds, Boolean useBounds, Boolean clearAllLayers) (at Assets/AwesomeTechnologies/VegetationStudio/TerrainSystem/TerrainSystem.cs:276)
    AwesomeTechnologies.TerrainSystemEditor.DrawGenerateInspector () (at Assets/AwesomeTechnologies/VegetationStudio/TerrainSystem/Editor/TerrainSystemEditor.cs:98)
    AwesomeTechnologies.TerrainSystemEditor.DrawAutoTextureInspector () (at Assets/AwesomeTechnologies/VegetationStudio/TerrainSystem/Editor/TerrainSystemEditor.cs:115)
    AwesomeTechnologies.TerrainSystemEditor.OnInspectorGUI () (at Assets/AwesomeTechnologies/VegetationStudio/TerrainSystem/Editor/TerrainSystemEditor.cs:72)
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor[] editors, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1374)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    The progress bar sits there, not progressing, and nothing happens to the terrain. I can still use Unity. I created a new scene, but the progress bar (or lack of) persisted - I had to quit Unity to get rid of it. I started with a blank terrain, with no textures, but set it to have four. Is this my fault? New to Vegetation Studio, only bought it recently. I hope this is something I have not done! Using 2018.2.5f1.
     
  39. JBT27

    JBT27

    Joined:
    Jul 13, 2016
    Posts:
    197
    Just a follow up. Pretty sure this is not something I am doing. It seems clear enough how to apply a four texture splatmap to a blank terrain. The above problem happens every time. I have to quit Unity.
     
  40. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,380
    I will have a look at the error tomorrow when back in the office.

    Lennart
     
  41. JBT27

    JBT27

    Joined:
    Jul 13, 2016
    Posts:
    197
    Thanks very much. I've been trying some more, and wondering if I have misunderstood. The terrain had no textures at all to start with. I appreciate I can use any other splat system, but I was hoping to start from scratch with Vegetation Studio. Hence this repeatable error. However, if I add four textures to the terrain beforehand (I was trying four in this case), then it seems to work fine. So I'm wondering if I simply misunderstood, and I have to add textures to the terrain(s) first.
     
  42. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    490
    Wondering if anyone has tried the new "ForestVision-Uni" trees and plants with VS?

    This version works off of Unity Trees so I would expect it to work better than the original ForestVision, but wanted to check to see if anyone has had any issues with it before buying.

    The dev just announced a price drop coming from $20 down to $10, it has over 100 trees so it looks like a great buy, just wondering how it works. Now just waiting on the store to change the price.
     
  43. XOA_Productions

    XOA_Productions

    Joined:
    Nov 27, 2016
    Posts:
    24
    Hey there!

    I've noticed a problem in both editor and builds when moving fast through areas with vegetation. Moving above a certain speed causes a lot of work on the main thread because of the preprocess() function. This only happens if the vegetation is rendered and not past the vegetationdistance:
    Editor:
    problem.PNG
    Build spike #1 (this one does not happen regularly I believe):
    problem2.PNG
    Build spike #2 (this one happens regularly when driving and drops my fps from 80 to around 40):
    problem3.PNG
    Build overall CPU graph when moving fast (60mph-ish), blue is VegetationSystem.Update(), with lots of spikes like build spike #2 :
    problem5.PNG
    Is there a way to make this consume less time? I understand that preprocess is doing the work based on the spawn-rules of the vegetation (?), so I get that it's just going to have to do some work, but the amount that it's doing is problematic. I tried moving all vegetation over into the persistent storage, as that would mean that no spawn rules have to be calculated, however, the problem was still there (although I did not profile that build, so the problem might have been something else in that case).
    Are there any settings on a vegetation item or the vegetation system that might cause this?
    I use EasyRoads which adds a vegetation mask automatically, however, I do have the same Issue pretty much everywhere, no matter if there are vegetation masks around, or not.

    Another question:
    When I profile the editor I get one call to VegetationSystem.Update() per frame, but in the build, this happens:
    problem5.PNG
    Is that normal? I do have multiple vegetation systems in my scene, but the camera was only in the range of one of the systems at the time, so I'm not sure why the update is called twice here.

    Regards
    Ben
     
    Last edited: Aug 28, 2018
  44. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,380
    Hi. Ben

    There is a few things that is possible to adjust.

    1. Looking at your first image. What takes time here is the multithreaded load vegetation.When moving around the map you will need to spawn new cells. The faster you move the chance of loading multiple new cells in a frame increases as the camera covers more area.

    These cells needs to be generated. Each cell will be spawned in a separate thread.
    This code is faster on a standalone build than in editor. It then uses a c++ dll for some heavier math.

    Reducing vegetation cell size can help on this as you would spawn smaller areas each frame but more often.

    Baking the vegetation to a persistent storage will help a lot with this also. Then the instances are ready and can just be loaded to the cell memory.

    2. The big spike you get in the 2nd image is 57ms of Garbage Collection. That is c# cleaning up used memory. This is a general problem in Unity and not under control of Vegetation Studio. A cleanup can happen anywhere in code that allocates memory on the heap. When loading new terrain tiles or cells it needs to allocate memory to store the data.

    This is getting a bit easier to manage with the new Job system and NativeArrays in Unity 2018.2+ Vegetation Studio Pro is using this. With NativeArrays you can allocate native memory that you manually clean up in. The GarbageCollector does not need to process this.

    3. This is the same as on image 1.

    4. When a vegetation system is completely out of range it should not process any render calls. This is based on a the vegetation Distance + Tree Distance and a buffer distance on top of this to not have to evaluate the cells in from a Quadtree all the time. When out of range it should not trigger.

    If you could join the Discord server and send me a message I can help you to do some adjustments. Easier on a text chat

    Lennart
     
  45. holdingjason

    holdingjason

    Joined:
    Nov 14, 2012
    Posts:
    102
    Hi. Great product. Hopefully a quick question on passing data into custom shaders. We use a custom shader to literally shake a specific tree when clicking on it by passing in some curvature values. Its a vertex shader and the values are setup as instanced parameters. However not sure going through Veg Studio how we would pass those values into the specific instanced tree as well as through the MaterialPropertyBlock.

    I did see how you passed the _Wind value that way which is great but not sure how to pass our own custom params. As far as getting access to the specific tree I think that is done through the collider system so will look into that further.

    Still digging through the docs and forums but have not seen this specific example yet, if I run across it first will be sure to close this out. Thanks a ton.
     
  46. LennartJohansen

    LennartJohansen

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

    We just had a similar discussion on the Discord forum a few days ago.

    There is a few ways to do this.

    1. Passing per instance data to the shader.
    Lets say you want to click on and shake a tree. When rendering trees the current render list is based on the visible cells in the vegetation system and the current frustum. This will change every frame as your camera moves. The index of the tree will then change.

    In order to find the current instance we would have to test all tree instances against the "ShakeList" identify the affected trees and fill data in an array the size of the number of total trees of the current model and LOD to render. This will then be added to the Material Property Block.

    This will work but it seems like a bit of overhead to go this way for a single shaking tree.

    2. The same could be done for instanced indirect rendered vegetation, but then in a compute shader on the GPU and faster.

    3. If you only need to shake a single tree use 2 global vector4 global shader variables. pass the tree position you get from the collider in Vegetation Studio as xyz in the first
    In the other vector4.xyz you pass a shake vector offset.

    in your vertex shader you test the localspace 0,0,0 transformed to worldspace distance to the first position passed. if this is less than xx set for floating point error you apply the offset to all vertices of the tree.

    All calculations will be done on the GPU and you use "0" CPU for your shake.

    Fast and easy way to get the effect with no changes needed to VS code.

    If you need multiple trees shaking I would look at option 2

    Lennart
     
  47. holdingjason

    holdingjason

    Joined:
    Nov 14, 2012
    Posts:
    102
    Thanks great that you reply so far. #3 should work fine, that was how we were doing grass deformation before switching to your tool. As far as any code behind stuff in c# I am guessing the idea is to use the Runtime prefab spawner to dump out some coconuts or whatever logic is needed while we do the shake? Actually to also trigger the shake operation as well by passing in the global shader variable vector. Correct?
     
  48. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,380
    The run-time prefab spawner I would use for effects that does not need any interaction. Like falling leaves from a tree etc. The run-time prefab spawned prefabs will happen without any user interaction.

    In your case you probably already have a script handling your harvesting logic added to the collider on the OnCreateCollider event.

    This script could just instantiate a falling coconut prefab as it would in any other code and let that destroy itself when done.

    Lennart
     
  49. LennartJohansen

    LennartJohansen

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

    Vegetation Studio has it own run-time vegetation spawner/generator but it can also import trees spawned by systems like gaia.



    Try this to get started and look at the youtube channel for more videos describing features and possibilities.

    The trees and grass you had on the terrain from before are not removed from the terrain, but Vegetation Studio turns of the drawing of the details and terrain trees. This is done by default setting since Vegetation Studio is a rendering system designed to replace the Unity terrains tree and detail system.

    You can import the finished trees spawned by Gaia using one of the importers on the Persistent storage component.
    https://www.awesometech.no/index.php/persistent-vegetation-storage/

    But I recommend setting up your spawning rules in Vegetation Studio. This way you can run-time change rules and density.

    Lennart
     
  50. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,483
    Thanks man I don't know why I didn't look at the videos on the side on the asset store page lol. I realized that right before you replied.
    I see how it all works now. Its soooooo good man.
    This asset will solve all my problems with work flow.
    so amazing it generates as I add a item. So ya I won't be using Gaia for generating trees, grass rocks or anything on terrain thats for sure.
    This is so superior.
     
unityunity