Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RELEASED] Vegetation Studio

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

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

    gghitman69

    Joined:
    Mar 4, 2016
    Posts:
    93
    TC2 is compatible and spawn vegetation but if you have more 15 terrain your computer explode :p

    TC2 is limit by your graphic card
     
  2. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    Hey everyone, I was just wondering what you are using to create your masks for VS. It's time to cut the forest down a little bit and create a few different biomes. What's the best way to do it?

    Cheers Andy
     
  3. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi Andy. If you want to make some manual painted masks there is a small helper component to get you started.

    Add a MaskBackgroundCreator component to the VegetationSystem object. select a resolution and press the button.



    This will render out a ortho image of the terrain with the correct area for a 1:1 mask of the entire terrain. You can use this as a temporary background in photoshop or gimp. This helps you draw mask colors on the correct place in the mask.



    then paint areas on the mask where you want different biomes.

    then add the saved mask as a texture mask (mask tab)



    and use this mask to set up texture mask include rules for the vegetation items.

    I have a bigger plan for biomes but I will get back to this later... :)
     
  4. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    That's fantastic. i didn't realise this. :)
     
  5. superkratos

    superkratos

    Joined:
    Sep 4, 2017
    Posts:
    112
    Mr Johansen, is there a way to adjust the touch react collider? With a thin boat like this, grass stick out a little in some area.. How can I keep a little distance?
    upload_2017-10-12_17-44-42.png
     
  6. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    From the image I guess you have a mesh collider on the boat and added a TouchBendCollider or TouchBendMesh component. What happens here is that the collider will render to a mask on the GPU that is used to modify the vertexes of the grass. If you are using the default grass mesh that is used when adding a Texture2D this is built from multiple low resolution planes. Some of the vertexes is probably ends out in the holes in the boat and are not affected. If the other side of the plane also is outside the boat it will not be affected by the mask.

    first step would be to make a custom grass mesh. Use the included grass patch generator and increase the width segments.

    https://www.awesometech.no/index.php/grass-patch-generator/

    Also consider adding a box collider under the boat that extends a bit outside. This could be a trigger collider to not affect any physics in your game. Add the touchbend collider component to this also.
     
  7. LennartJohansen

    LennartJohansen

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

    Another small development update.

    After a request from one of the beta testers yesterday we started looking at a fast way to exclude existing objects with colliders in the scene from spawn areas. Direct raycasting when doing run-time rule based spawning is to slow, and also does not support multi thread spawning. We ended out with the idea of a system for generating an occlusion mask from the scene. This tool is now finished.



    Add a Obstacle Mask Creator component to the same GameObject as the VegetationSystem.
    Select obstacle layers, mask resolution and an optional minimum distance.

    Then generate the mask. From the included demo scene it generates a mask like this.



    Not much in that scene but if we zoom closer in on the bay area.



    Here we have some GameObjects set up with colliders.


    The mask for this area looks like this and can be used as a texture exclude mask on the vegetation in VegetationStudio.

    There is also an option to add a minimum distance from available spawn location to colliders in the scene.


    This is the same area with a 2.5 meter additional masked out distance.
     
  8. superkratos

    superkratos

    Joined:
    Sep 4, 2017
    Posts:
    112
    upload_2017-10-13_11-22-30.png
     
  9. superkratos

    superkratos

    Joined:
    Sep 4, 2017
    Posts:
    112
    I use patch generator with a width segment of 5 and a capsule collider. Seems much better now! Thanks, Mr Johansen!
     
  10. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    Just found this, looks fantastic! Don't spose any of the beta testers is currently using this with AFS?
     
    AndyNeoman likes this.
  11. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    I have tested plants with the AFS shaders, that worked good. You also need to add the AFS component for it to control wind for the plants/tree.

    I also think some of the beta testers have been using the Tropical Forest Pack asset, that is also using shaders from Lars. The Custom Tree importer tree shader.
     
    GoGoGadget and Teila like this.
  12. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    Hi there,
    any news about the MapMagic integration?
    And about multi-threading, is VS auto multi-threaded or there is an option to use more threads?
     
    Last edited: Oct 15, 2017
  13. LennartJohansen

    LennartJohansen

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

    Vegetation Studio uses multi-threading by default. You can disable this in the render tab of the VegetationSystem component. The multi-threading is used in 2 parts of the run-time loop, when you load new cells as you move the camera and for building up the current visible lists to use with the instancing AP.


    MapMagic produces standard Unity terrains and these work with Vegetation Studio. You can add a Vegetation Package to these terrains and spawn vegetation with Vegetation Studio.
    There is also an included plugin that helps you set up this when using the infinite terrain feature of MapMagic.
    http://www.awesometech.no/index.php/set-up-with-map-magic-infinite-terrain/

    Vegetation Studio has an API for the persistent storage, this allows 3rd party systems to feed instances of trees, rocks and plants. I have been talking to Denis (MapMagic developer) about creating a output node for MapMagic that can feed this API. This is something we will look more at after I get the release version of Vegetation Studio ready. This is my main focus right now.

    Lennart
     
  14. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    Yes, I use AFS and it works great with VS.
     
    GoGoGadget likes this.
  15. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    The output nodes from MM to VS would be the best, for MM has many inner data I need to generate foliage but VS can not use them by default.
    Look forward for the release and further integrations!
     
  16. superkratos

    superkratos

    Joined:
    Sep 4, 2017
    Posts:
    112
    Hi, Mr Johansen. About the Color Mask Generator, can we deal with different color of grass in the distance? I tried to bake color mask of two types of grass with different color and got this error..
    upload_2017-10-17_15-9-5.png
     
  17. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    1. HI. What resolution did you try to render the mask to? It looks like Unity has a render texture max size on your computer. What graphics card?

    2. The VegetationColorMask is using a override shader to render an unlit version of the vegetation in the terrain. It will read colors from any texture set up as _MainTex in the shaders. It does not know about any color correction done on shader level. If you have a custom shader with color tint etc.

    The problem with rendering to the mask with the original shaders are that they would get light from the scene and then get light again when used on the terrain. With some manual adjustments and only using an indirect light you could maybe get this to look good.

    I will expose some settings for users to play with when creating a vegetation color mask, but this will be in an update after 1.0 release.
     
  18. LennartJohansen

    LennartJohansen

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

    The last few days I have been working on an optional rendering pipeline that gives some interesting options. It can be used for all vegetation items with shaders that support Vegetation Studios instanced indirect implementation. I have an include file that makes it easier to add support to existing shaders. 2 extra lines of code in the shader.



    As some of you might know Vegetation Studio has support for using the Instanced Indirect rendering API.
    This renders instances of a mesh(grass, flowers etc.) that is stored on a compute buffer on the GPU.

    This does not have the max limit of 1023 instances per call as the normal instancing API has and also is faster as you do not need to transfer the Matrix array to the GPU every frame.

    Internally vegetation studio splits the terrain in cells and handles culling/loading/spawning of these cells.
    Using the new pipeline the I am able to combine the compute buffers of each visible cell to a common buffer using compute shaders on the GPU. This final buffer is then rendered in a single call. This is 1 call to the Graphics.DrawMeshInstancedIndirect API per grass/plant type in the terrain.

    Having all instances in a single buffer before rendering gives some possibilities.
    With an additional computeshader pass on the buffer we can do:
    • Frustum culling to remove instances outside of camera view on partial visible cells. This will remove the instances from the rendering loop and save the vertex shader work on these.
    • Vegetation distance culling, removing instances on loaded cells that are beyond the vegetation far distance.
    • Individual LODs per VegetationItem. Using multiple Append Buffers we can filter the instances based on distance and this way manage LODs on each item. This would be to slow to on the CPU due to the amount of instances involved. When done on CPU the LOD level would be per cell.

    This could also be extended for other per item calculations as the structured buffer can be extended to pass more per instance parameters to the shaders.

    I will do a post later today or tomorrow on the general development status and plan for release.


    Here are the per item LOD settings available on grass and plants when using the compute shader rendering loop on instanced indirect shaders.

    Lennart
     
    Olander, AndyNeoman, malkere and 2 others like this.
  19. superkratos

    superkratos

    Joined:
    Sep 4, 2017
    Posts:
    112
    It's weird! I use a upload_2017-10-17_16-57-17.png card, by the way. The first time I rendered a 4096 image with only one type of green grass and it worked. And the second and third time I rendered a 2048 and 1024 image with two types of grass with different color and it crashed and reported like this.
    upload_2017-10-17_17-0-21.png
     
  20. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    I will send you a PM to get more details
     
  21. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Today's update.

    I wanted to show some of the possibilities of having a compute shader based render pipeline.
    As I told in the post yesterday there is now an optional render pipeline that renders all the instanced indirect supported vegetation using compute shaders to prepare the final render lists.

    This gives the possibility to do per item calculations in the final compute shader pass before rendering. I have added a new system. Real-Time masking.


    This allows you to assign any Texture2D or RenderTexture that covers the entire terrain as a real-time mask.
    You select channel and a cutoff value and the result is used to mask out vegetation. This can be done with animated masks as the masking is done every pass in the compute shader at close to 0 cost.

    In these example images I used a mask I created with the ObstacleMaskCreator component as an example.

    Here is a closeup of the village area.


    As you can see the vegetation for the house area is masked out.

    If I inverse the mask you get this result.


    But let us try this on an animated mask. :)
    I set up a scene with MicroSplat and used the lava system to produce a lava flow down the mountain side.
    Then used the flow control map microsplat produces and assigned it as a real-time mask.

    Microsplat needs a small change for me to get access to the buffer, but I will sync with Jason to get this in his next update.

    The general idea is that this will work with any mask you produce.

    What do you think?



    Lennart
     
    Olander, LittleMike, mons00n and 10 others like this.
  22. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    Any near plans for mesh support?
     
  23. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi. Mesh support is something I want to work on on for an update after release. Plan is to support standard terrain meshes and Terrafirma terrain using the same interface. I have no set deadline for this yet. There is a list of other features that will be added first.

    I will keep you all updated as development continues.
     
    Mark_01 and malkere like this.
  24. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    ice2011 and Mark_01 like this.
  25. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    Hi Lennart, is there a guide for making foliage shaders compatible with your/unity's instance indirect rendering?
     
  26. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    No. I will make the guide next week. but the conversion is easy. I have a include file that holds the functions needed. This I will make available to download from the webpage. In addition to this you need 3 lines of code in the original shader. If anyone wants to they can include this file in other assets. Adding support for my instanced indirect implementation does not break normal use of the shader.

    Code (csharp):
    1.  
    2.  
    3. //add the pragma settings with the other
    4. #pragma instancing_options procedural:setup
    5. #pragma multi_compile GPU_FRUSTUM_ON __
    6.  
    7. //and with the other file includes
    8.  
    9. #include "a_indirect.cginc"
    10.  
    This will give you support for instanced indirect rendering and the scale/fade of the grass at vegetation distance. This is set up for single material meshes but when I get time I will add multi material support to the instanced indirect pipeline also.
     
    Last edited: Oct 18, 2017
    Mark_01 and AndyNeoman like this.
  27. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    two questions
    1) does this work on mobile
    2) do you have some way to support for wind zone? I want to be able to put a fan or a helicopter and the wind move the grass. I see you have touch based grass but not sure how well that works to simulate a wind propeller on it
     
  28. LennartJohansen

    LennartJohansen

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

    1. The system is designed to use Shader Model 5.0 with the new instanced and instanced graphics API. It also uses compute shaders for part of the rendering loop.

    For mobile, compute shaders are only available on Metal and Vulcan. You could probably get the system running on ShaderModel 4.5 (OpenGL ES 3.1) but with a bit reduced functionality. There is settings to configure this.

    You should be able to use it latest generations iphone/ipads and the high end android phones but it will not work on older phones.

    2. There is directional wind zone support for the grass but no localized wind zones.

    The compute shader based rendering pipeline allows for individual calculations on each instanced of grass while rendering. In theory localized wind could be injected here, but this would require a some changes to the wind algorithm in the shader also. Something I could prototype in the future but not on the short time roadmap.

    Lennart
     
  29. LennartJohansen

    LennartJohansen

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

    Hi.

    I am getting closer to a first version of Vegetation Studio.
    I have a couple of reported bugs and a change to the cache system left to do.

    My plan is to finish this by the end of the week and use the next week to update the documentation and start doing videos to explain features and use cases.
    After a week of documentation updates I want to send this to Asset Store for review.

    Since the review seems to take 3-4 weeks now my plan is to continue sending updates to the beta group and have a 1.1 update ready when Vegetation Studio hits the Asset Store. I have a list of future features to add and no need to wait the month while it gets approved.

    Thanks for the help beta testing until now! :)

    Lennart
     
  30. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    I managed to reproduce the error on another computer. Looks like unity does not like the millions of instances rendered on some machines. I will split the mask rendering to tiles. and combine the result. Should fix the issue.

    Lennart
     
  31. LennartJohansen

    LennartJohansen

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

    I started the documentation job, but as I was working on the Mask system I found a couple of things that could be easier.

    Until now when you add a VegetationAreaMask to any GameObject you would manually have to set the points of the mask relative to the GameObject.



    There is now a Generate Hull outline button.

    This will analyze all meshes in the GameObject and children objects. Convert all points to worldspace and calulate the projected outline of the meshes using a monotone chain convex hull algorithm. Then reduce the complexity of the outline with a Douglas Peucker reduction.

    the result is a finished outline for the object. You can then modify this as needed.



    For the last image I also added an additional remove distance for trees and objects in while reducing the accuracy of the hull outline.



    This will be an option on the inspector or in the API if you add masks by code, but I will probably add this as normal behavior when adding a mask to an object with a mesh.

    Lennart
     
  32. RonnyDance

    RonnyDance

    Joined:
    Aug 17, 2015
    Posts:
    557
    This is really great. It took some time to move the point of the mask to the right place to get good results. Often you also need to add more points etc. So a feature which is faster is a great thing.
     
    antoripa and LennartJohansen like this.
  33. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Todays update.

    I just added a new feature to the ColliderSystem component. In addition to adding colliders to trees and objects you can now add NavMeshObstacles.



    You can add capsule or Box obstacles with all the settings of the NavMeshObstacle component exposed.



    As you can see from the video this will carve out trees in the NavMesh as you move around the map.

     
  34. LennartJohansen

    LennartJohansen

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

    While taking screenshots for the documentation I did some restructure of the GUI for the VegetationSystem component.
    All settings for VegetationItems are now grouped and made expandable. This is remembered between sessions.



     
    Last edited: Oct 23, 2017
    Stardog, Mark_01, rrahim and 4 others like this.
  35. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    Hi,
    Is Navmesh carving fast enought when there is lot of trees and objects around the player ?
     
  36. gegebel

    gegebel

    Joined:
    Jan 29, 2014
    Posts:
    469
    Is there a release date and a price tag already? Would be good to know. thx
     
  37. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    It seems to be working at good speed. I did some flying around at fast speed in a development build with profiler to check the result.

    On this frame on the image multiple cells with vegetation are loading including several trees that are configured to carve the NavMesh.

    As you can see it seems to be using 0.45ms on the main thread and around 1ms on a worker-thread to carve the navmesh. I did see a frame with 2 jobs on the worker thread. Main-thread work was still less than 0.5ms.

     
    ZoneOfTanks and zenGarden like this.
  38. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    It looks good.
     
  39. antoripa

    antoripa

    Joined:
    Oct 19, 2015
    Posts:
    1,163
    Sentieri Beta 0.4.6 .. Procedural Road Level Design .. integration with Vegetation Studio

     
  40. ZoneOfTanks

    ZoneOfTanks

    Joined:
    Aug 10, 2014
    Posts:
    128
    Can't wait to test this system :)
     
    LennartJohansen and antoripa like this.
  41. lanrosta

    lanrosta

    Joined:
    Oct 11, 2014
    Posts:
    26
    Would be cool to modify the GUI a bit. For example on the Vegetation System panel, maybe remove the fields for dropping prefabs for Grass, Plants, Trees, etc and make those 'drop' squares in a row above the area where the prefabs are shown as a gallery of squares. Drag and Drop behavior is the same, it would just take up less vertical space and look a little more slick
     
  42. lanrosta

    lanrosta

    Joined:
    Oct 11, 2014
    Posts:
    26
    Is there a way to remove the grass details by a function call from other scripts? I currently have a script that removes Unity Terrain Details from a small radius area on click by iterating the detail layers and modifying the SetHeight of any objects in the direct vicinity of the click. I would like to be able to do the same using VS. How would I do this?
     
  43. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    I will play with it and see how it looks. Maybe design some icons for Grass, Plant, Tree, Object and Large Object. For the drop zones.

    Edit: If anyone are good at designing icons some input would be great :)

    Lennart
     
    Last edited: Oct 25, 2017
  44. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    If you have the Vegetation baked to the persistent storage you can do this with a call to the API. If you are working with procedural run-time spawned vegetation you can get the same effect with creating a VegetationMask. I can add a Circle/sphere vegetation mask component you can add. There is also an API for adding masks direct if you want to handle that.

    I am working on documentation these days. The persistent storage doc is probably ready tomorrow or Friday.
     
  45. lanrosta

    lanrosta

    Joined:
    Oct 11, 2014
    Posts:
    26
    I'll design some icons tonight with a couple different options for size and layout. Will also go through other dialogs and see if there is anything else that could use a UI improvement.

    For the grass removal thing, I would need to do this at run-time (think about what would cause damage or removal of Details in real-life cases; ie. burned, explosion, harvesting, cutting, etc.) so would definitely need an API call that I can specify a Vector3 point, a float for the radius, and would be great to also provide an int array specifying the Details layers that I want to affect/remove in the call. Even better, instead of radius, a texture map with size value. Make sense?

    Also, is there a way to use the touchbend grass, but keep it bent after it has been stepped/driven over in game, so it will leave a path in the Details layers?
     
    ZoneOfTanks likes this.
  46. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Another development update.

    Extending some functionality while I should be writing documentation...

    I have now enabled a 2nd level object culling for trees on top of the cell based culling.
    It calculates visibility in the same pass as I calculate LOD levels.

    To get shadows correct and avoid shadow popping I am also doing a shadow visibility culling on the invisible trees based on the sunlight orientation.

    There is a new setting on the render tab where you can assign a directional light used for the shadow culling.
    Yo can also set the distance where load extra trees to test for shadows visibility.





    Lennart
     
  47. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    You can do all this. I will explain a bit in a post tomorrow. Getting late and I have a few more things to finish today.
     
    malkere likes this.
  48. lanrosta

    lanrosta

    Joined:
    Oct 11, 2014
    Posts:
    26
    awesome! Thanks Lennart.
     
  49. mwituni

    mwituni

    Joined:
    Jan 15, 2015
    Posts:
    345
    Just to mention, there's really good libraries online, eg:

    There's 578 000 at flaticon.com for $10 for month access (free for personal use)

    Or 99 000 for free (any use) at www.freepik.com/free-icons
     
    malkere likes this.
  50. MortenGulden

    MortenGulden

    Joined:
    Mar 15, 2015
    Posts:
    19
    Just playing with the most recent updates, the additional GPU-stuff Lennart has done really allows me to increase grass and tree render distance by a lot, and the integration with Sentieri and Microsplat (among others) is great!

     
    Mark_01, malkere, jbooth and 7 others like this.
Thread Status:
Not open for further replies.