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

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    835
    Happy New Year from the East Coast of America!
     
  2. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    What kind of grass?
     
  3. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Happy new year guys & girls! :)

    What grass/trees pack is best for 2018? :D
    With best visuals and performance :D
     
  4. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Thank you!
     
  5. Hikiko66

    Hikiko66

    Joined:
    May 5, 2013
    Posts:
    1,304
    I'm going to assume it's you're speedtree ambient occlusion + whatever ambient occlusion you are using in unity that is causing all those shadows. From what I can see, in speedtree you can't really just tweak the AO per Tree, you actually have to go tweak it per level group.

    You can check to see if it's the speedtree AO by clearing it and exporting the tree without it, it will look a lot less dark, but it will also look quite flat.

    If you want to export some AO from speedtree, you'd have to tweak those settings to work well with whatever AO you are using in unity.
     
    Last edited: Jan 1, 2018
    coverpage likes this.
  6. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi. I have not tried this but I think it could work. The Navmesh bake feature of the ColliderSystem component can bake out all configured colliders on trees and rocks to meshes or colliders in the scene. This you can probably use to generate the navmesh in Astar.

    Another option could be to connect to the Create event on the ColliderSystem and add the AStar NavmeshCut component to the created colliders gameobject. This should carve out a holde in the navmesh for the tree.
    See the collider system doc for more info on the event.

    This is simlar to what Vegetation Studio does with the dynamic obstacles for the Unity Navmesh.

    This video shows the dynamic obstacles on the Unity Navmesh as the camera is moved on the terrain.

    Lennart

     
    blitzvb likes this.
  7. OfficialHermie

    OfficialHermie

    Joined:
    Oct 12, 2012
    Posts:
    585
    The extended demo scene has the house materials missing when built (materials appear white when built).
    And you should contain an FPS counter by default (you could have a look at "Easy Main Menu" to check out how wonderfully they do it, they have an FPS counter script and tell the user to import it from Standard Assets).
    fps1.jpg
    Sure everybody can do it on his way, but since FPS is so important in your assets, I'd recommend doing it as they did it.
     
    Last edited: Jan 1, 2018
  8. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Are you using 2017.3? You need to rebake the lighting in the scene.

    I do not have any FPS counter code, but I will add it to the list and make one. Not a big job.

    Lennart
     
    OfficialHermie likes this.
  9. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    So if I want to spawn stones with VS and use the feature so grass dosent grow thrue the stone.. I have to add the component on the stone before dragging it to VS?
     
  10. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    No. That is different. For rocks spawned with VS you only click the setting on the VegetationItem., This will render the rock to the TouchReact buffer automatic. The component is for objects that is not spawned by VegetationStudio but in the normal Scene.

    Lennart
     
    mattis89 likes this.
  11. jlocke

    jlocke

    Joined:
    Dec 16, 2017
    Posts:
    62
    We got a copy of Vegetation Studio. Congratulation for your innovative approach. We are going to prototype something using the asset in the week and will share it. Thanks
     
  12. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Great :) Just send me a pm if you have any questions or ideas :)

    Lennart
     
    Mark_01 likes this.
  13. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
    I toyed around some more with runtime mask generation, this time by using collision with a sphere that's rolling down a hill. Looks like this:



    In case someone else wants to toy around with it, here's the code.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using AwesomeTechnologies;
    5.  
    6. public class RuntimeCollisionMask : MonoBehaviour {
    7.  
    8.     /// <summary>
    9.     /// The terrain of which to get the dimensions of the mask
    10.     /// </summary>
    11.     public Terrain terrain;
    12.  
    13.     private VegetationSystem vegetationSystem;
    14.  
    15.     private Color maskForeground = Color.green; // color must match the RealTimeMaskBand channel
    16.     private Color maskBackground = Color.black;
    17.     private float maskSizeFactor = 1.0f;
    18.     private int maskCollisionCircleRadius = 1;
    19.  
    20.     private Texture2D mask;
    21.  
    22.     void Start () {
    23.  
    24.         ///
    25.         /// Create Mask
    26.         ///
    27.         Vector3 maskSize = terrain.terrainData.size;
    28.  
    29.         int maskWidth = (int) (terrain.terrainData.size.x * maskSizeFactor);
    30.         int maskHeight = (int) (terrain.terrainData.size.z * maskSizeFactor);
    31.  
    32.         mask = CreateTexture2D( maskWidth, maskHeight, maskBackground);
    33.  
    34.         ///
    35.         /// Setup Vegetation Studio
    36.         ///
    37.  
    38.         // get vegetation studio
    39.         vegetationSystem = GameObject.FindObjectOfType<VegetationSystem>();
    40.  
    41.         // consistency check: feature works only with compute shaders enabled
    42.         if (vegetationSystem.UseComputeShaders == false)
    43.         {
    44.             Debug.LogError("Compute shaders in Vegetation Studio must be enabled");
    45.         }
    46.  
    47.         // Set the color channel for the masking
    48.         vegetationSystem.RealTimeMaskBand = TextureMaskBand.GChannel; // channel must match the mask foreground color
    49.  
    50.         // enable realtime masking
    51.         vegetationSystem.RealTimeMaskEnabled = true;
    52.  
    53.  
    54.     }
    55.  
    56.     void Update () {
    57.  
    58.         // set mask in vegetation studio
    59.         vegetationSystem.RealTimeMaskTexture = mask;
    60.  
    61.     }
    62.  
    63.     void OnCollisionStay(Collision collisionInfo)
    64.     {
    65.         foreach (ContactPoint contact in collisionInfo.contacts)
    66.         {
    67.             // only support terrain collisions
    68.             if (contact.otherCollider.GetType() != typeof(TerrainCollider))
    69.                 continue;
    70.  
    71.             Terrain terrain = contact.otherCollider.GetComponent<Terrain>();
    72.  
    73.             Vector3 point = terrain.transform.worldToLocalMatrix.MultiplyPoint( contact.point);
    74.  
    75.             int x = (int) ((point.x / terrain.terrainData.size.x) * mask.width);
    76.             int y = (int) ((point.z / terrain.terrainData.size.z) * mask.height);
    77.  
    78.             // mask.SetPixel(x, y, maskForeground);
    79.             Circle(mask, x, y, maskCollisionCircleRadius, maskForeground);
    80.  
    81.             mask.Apply();
    82.  
    83.         }
    84.     }
    85.  
    86.     /// <summary>
    87.     /// Create a texture with the given dimensions and the fill color
    88.     /// </summary>
    89.     /// <param name="width"></param>
    90.     /// <param name="height"></param>
    91.     /// <param name="color"></param>
    92.     /// <returns></returns>
    93.     private Texture2D CreateTexture2D(int width, int height, Color color)
    94.     {
    95.         Texture2D texture = new Texture2D(width, height, TextureFormat.ARGB32, false);
    96.  
    97.         Color32[] pixels32 = texture.GetPixels32();
    98.         for (int i = 0; i < pixels32.Length; i++)
    99.         {
    100.             pixels32[i] = color;
    101.         }
    102.  
    103.         texture.SetPixels32(pixels32);
    104.         texture.Apply(false);
    105.  
    106.         return texture;
    107.     }
    108.  
    109.     /// <summary>
    110.     /// Draw a filled circle
    111.     /// </summary>
    112.     /// <param name="texure2D">The texture</param>
    113.     /// <param name="cx">Center X</param>
    114.     /// <param name="cy">Center Y</param>
    115.     /// <param name="r">Radius</param>
    116.     /// <param name="color">Fill Color</param>
    117.     public void Circle(Texture2D texture2D, int cx, int cy, int r, Color color)
    118.     {
    119.         int x, y, px, nx, py, ny, d;
    120.  
    121.         for (x = 0; x <= r; x++)
    122.         {
    123.             d = (int)Mathf.Ceil(Mathf.Sqrt(r * r - x * x));
    124.             for (y = 0; y <= d; y++)
    125.             {
    126.                 px = cx + x;
    127.                 nx = cx - x;
    128.                 py = cy + y;
    129.                 ny = cy - y;
    130.  
    131.                 texture2D.SetPixel(px, py, color);
    132.                 texture2D.SetPixel(nx, py, color);
    133.  
    134.                 texture2D.SetPixel(px, ny, color);
    135.                 texture2D.SetPixel(nx, ny, color);
    136.             }
    137.         }
    138.     }
    139.  
    140.  
    141.  
    142. }
    143.  
    Usage:

    * create sphere with rigidbody
    * add above script to it
    * assign terrain to the script's property in inspector (that's really only to get the dimensions for the mask)
    * enable compute shaders in Vegetation Studio

    Could use some optimization, in case anyone finds the time, please do share :)
     
    Last edited: Jan 2, 2018
    lawsochi, antoripa, Mark_01 and 2 others like this.
  14. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi. Had a quick look at the script. You can use the static API on the VegetationStudioManager to get all VegetationSystems in the scene. If you use that and assign the mask texture to all vegetation systems this will work on multiple terrains also.

    Lennart
     
    antoripa and Rowlan like this.
  15. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Okay, I see.. What can I do if I see grass straws still going thrue the stone or whatever?
     
  16. jessejarvis

    jessejarvis

    Joined:
    Aug 9, 2013
    Posts:
    303
    Hiya!

    I'm the creator of a project called Hexa Heroes Online, I'm gonna showcase some of the screenshots of the game using Vegetation Studio!

    Progress screenshots are at http://patreon.com/cunningfoxstudio

    2018-01-01_9.png 2018-01-01_7.png 2018-01-01_4.png 2018-01-01_5.png 2018-01-01_10.png

    So Vegetation Studio works great for low poly assets as well! It's amazing.
     
  17. Rastapastor

    Rastapastor

    Joined:
    Jan 12, 2013
    Posts:
    589
    Small Forrest :)

     
    Last edited: Jan 2, 2018
  18. jlocke

    jlocke

    Joined:
    Dec 16, 2017
    Posts:
    62
    Nice shot ..
     
  19. Rastapastor

    Rastapastor

    Joined:
    Jan 12, 2013
    Posts:
    589


    Created some speedtrees variants, the trees i used before are not suited for VS so the performance was bad :).
     
    P_Jong and BackwoodsGaming like this.
  20. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Hey! How can I know what trees goes hand in hand with VS? I dont like speedtrees...they lool weird when it gets dark..shining so bright and the billboard function is ugly if you stand on a mountain and look further in the horizonish....
     
  21. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151

    Aaahaaaa...so the bend function is mask based its not vertex bent like afs?
     
  22. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    @LennartJohansen hello! The AFS grass shader with bend function does it work with VS?(I mean, good performance and bendable)
     
  23. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
    What I posted has got nothing to do with bending, I didn't activate bending. You can see that there's no bending, but only masking better here. It's just a simple circular shape that I draw on the mask at the sphere's location:



    The goal is to get a natural masking for ways and rivers by creating a dynamic mask for later usage by having balls run down a hill and basically using the natural way, i. e. Unity physics. I'd like to lower the terrain there and remove the grass by saving the mask and using it later.

    I tried bending after I posted this though by adding the touch react system. Could be interesting to have the grass first bend and then disappar with the mask :)
     
    Last edited: Jan 3, 2018
    LittleMike and mattis89 like this.
  24. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Okay I see what you mean.. maybe not disappear? Maybe just stepped down you know.? That would be realism :)
     
  25. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Cant get the vegetation masking to work for obstacle... the grass still spawns inside the houses... I made the mask, and assigned it. But what type should I choose?
     
  26. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
    Of course. It really was only a quick test. I thought I'd share, maybe someone finds the time to improve it :)
     
    mattis89 likes this.
  27. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
  28. RonnyDance

    RonnyDance

    Joined:
    Aug 17, 2015
    Posts:
    557
    What Speedtree Variants are not suited for VS? I am using lot of dekstop speedtrees with VS and didn't have that in mind.
    You mean Speedtrees are not suited because Instancing is not working for them at the moment?
     
  29. Rastapastor

    Rastapastor

    Joined:
    Jan 12, 2013
    Posts:
    589
    The shader of the tree needs to support gpu instancing :).

    As for the speedtrees, from what i know the Speedtree billboards are ignored when using VS, VS uses its own system :). Personally i like speedtrees over trees i've got so far, perhaps only photogrammery trees are better

    @RonnyDance

    Nono speedtrees work great with VS, what i meant by variants, i made couple of trees :). I took one tree and modify it. From one tree i got 5 trees :).
     
    mattis89 and RonnyDance like this.
  30. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi. Most shaders will probably work good. To get a good speed they need to support instancing. In some cases you need to add an extra component in order to inject wind.

    Lennart
     
  31. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Could you send me a pm with the settings you have when you assign the mask. Just to see if there is anything wrong?

    Lennart
     
  32. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    The demo video/gif Rowlan did is not related to the touch bend system. He was using a run-time masking feature that can be used to remove vegetation. You can get grass to bend and stay down with the right setup. Have a look here.

     
    mattis89 and antoripa like this.
  33. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    The AFS shader works with Vegetation Studio, but not the bend part. It requires GameObjects with colliders and scripts in order to set the proper per instance variables to affect the bend. I have talked to Lars to see if we can set up a framework to feed per instance info into the render loop but this is a bit of work.

    Lennart
     
  34. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Thats cool :) good work! This masking you made would be useful for fire etc..:) I think :D I could use it!
     
  35. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
  36. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Yes.. That I would like to achieve but with animals/monsters.. Possible to get the grass back up after a time?
     
  37. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Yes I will. Im at work atm, doing it tonight :) thanks!
     
  38. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Do I have to do the codepart thats in your docs or did lars allready intergrate it?
     
  39. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Yes, but most shaders I could make instanceable with your tutorial on the homepage?
     
  40. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Cool! Maybe Im gonna try one tree.. xD :D
     
  41. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    The guide on the webpage is to make an instanced shader support the Instanced Indirect implementation of Vegetation Studio.

    Since Unity 5.6 most shaders will instance automatic just with the checkbox on the Material, but not all of them. Some need som manual changes.
     
  42. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Lars updated AFS to support VS a couple of weeks ago. You should be able to use it direct.
     
    mattis89 and blitzvb like this.
  43. rasto61

    rasto61

    Joined:
    Nov 1, 2015
    Posts:
    352
    could someone who has afs make a comparison with the default VS grass shader in terms of looks and performance?
     
    blitzvb likes this.
  44. blitzvb

    blitzvb

    Joined:
    Mar 20, 2015
    Posts:
    284
    Same here. I really would like to see that.
     
  45. Candac59

    Candac59

    Joined:
    Sep 18, 2015
    Posts:
    106
    Hi, when VS initialized, pixel error chnage automatically from 1 to 5. Where i can change this in VS for put pixel error to 1 ? And i have other question, i use VS with Mapmagic and CTS, i use CTS node in my mapmagic table and i want use terrain textures rules for spawn vegetation with VS but for compatibility VS with CTS i haven't got texture in VS profile.
    Is there another way to do with CTS ?
     
  46. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    There is a setting on the settings tab on the Vegetation System component. Just uncheck that and you can set it to what you want.



    Yes. you can do this.
    What you need to do is as follows.

    Select the Vegetation Package in the inspector and duplicate as a backup.
    Change the number of textures to the amount you have in the terrain.

    Then drag and drop the terrain in the copy textures from terrain slot.
    Make sure the Update Terrain Textures on init is not checked.

    You should now have a vegetation package with textures that can make splat rules but does not update the terrain. CTS will handle that.



    Lennart
     
  47. jlocke

    jlocke

    Joined:
    Dec 16, 2017
    Posts:
    62
    awesome .. .
     
  48. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Okay, so it is instanced indirect? I guess I want to use that for grass and bushes, probably everything.
     
  49. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Im on it .. importing now.. i post at night.. finnish time :D
     
  50. jrackley

    jrackley

    Joined:
    Jan 26, 2017
    Posts:
    55
    I have a question about map magic and VS. I am using pinned terrains in map magic (16 of them), and I followed the instructions you gave earlier about copying the vegetation component to each of the pinned terrains. The problem, is that the trees, grass, etc... on the other terrains are floating way above the terrain. Do you know how to fix this?
    Floating trees A.PNG Floating trees B.PNG
     
Thread Status:
Not open for further replies.