Search Unity

[RELEASED] Vegetation Studio

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

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

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    I notice i can only see grass on Scene view and not on camera view.
    I checked the demo theres no extra component I need it seems.
    Shows on both on the demo just not on my own scene.

    Also will be getting better performance if I was using Unity 2018 instead of 2017?
     
  2. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi. In editor mode the vegetation is based on the sceneview camera, in playmode the camera you assign to the VegetationSystem component.

    I do not think performance has changed much between 2017 and 2018 versions but there is some new capabilities.

    Join the Discord chat and send me a message and I can help you optimize a bit. Easier with a text chat.

    Lennart
     
  3. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    647
    Hello guys!
    We want to share with You screenshots and trailer of our game " The End of the Sun", where we used Vegetation Studio a lot.

    CLICK HERE TO WATCH TRAILER

    Lennart if You need You could post screenshots and trailer on Your webpage or assetstore to promote Vegetation Studio, just add somewhere link to our webpage.
    CLICK HERE TO VISIT OUR OFFICIAL WEBSITE

    We hope You 'll like it and add our game to steam wishlist :)
    CLICK HERE TO VISIT OUR STEAM STORE PAGE












    RELEVANT LINKS


    Game’s official website: http://www.endofsun.com

    Facebook: https://www.facebook.com/EndOfTheSunGame

    YouTube Official: https://www.youtube.com/channel/UCFoSXpa4XVRZEC...

    Instagram: https://www.instagram.com/endofsungame/

    Twitter: https://twitter.com/endofthesungame

    Gamedev blog: https://www.endofsun.com/blog/

    Screenshots and gameplay materials: https://www.endofsun.com/#Gallery
     
  4. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Ran into a giant issue just now sadly. Went afk for a few hours and when I came back my editor is all frozen up?
    I have a super nice computer too.
    really bummed about it. Was really hoping to use Vegetation studio.

    I just checked Task manager in windows 10 and there is a memory leak going on.
    Unity is using 5GB right now and its slowy increasing about a 1 mb every 5 seconds.
    I have 17GB of memory unused right now. so I'm not out of memory.


    Also I noticed when unity is running all my other software starts majorly lagging. browsers messengers etc....
     
    Last edited: Aug 30, 2018
  5. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Sent you an email asking for some info. Need to try to replicate the issue.

    Lennart
     
  6. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Hello my friend! Have you made the fix for rocks and trees so they not collide? :) Because masking didnt work for me. Also, when I bake to storage and paint, is there anyway to forget about the rules and just let me paint where ever I want? :)
     
  7. anpd03

    anpd03

    Joined:
    Aug 7, 2013
    Posts:
    65
    Looking into if Vegetation Studio is right for our current project. Can I remove vegetation from code, I want to place a building from code and remove all vegetation around it, and if I remove the building later the vegetation shouldn't come back.
     
  8. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi. There is a couple of ways to do this.

    By default vegetation in VegetationStudio are spawned procedureally run-time from rules. This will give you vegetation based on height, steepness, noise settings, terrain textures etc. depending on your setup.

    This vegetation can be controlled run-time by VegetationMasks. This allows you to create mask areas that filter out vegetation for areas. These can also be added pre configured to prefabs.

    If you added this to a house and removed it, the vegetation would normally come back. But you could leave the mask component in the scene on an empty GameObject if you wanted vegetation to stay removed after you remove the house.

    another option could be to bake all the vegetation to the persistent storage. It will then be instances that you can manipulate and remove with the API.

    Lennart
     
  9. anpd03

    anpd03

    Joined:
    Aug 7, 2013
    Posts:
    65
    Hi Lennart, thanks for the quick response. That sounds like it could work. Will give it a go!
     
  10. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Great, just message me if you have any questions about the API. Or join the Discord server. Good way to get some ideas and help from me or other users.

    Lennart
     
  11. LennartJohansen

    LennartJohansen

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

    1. When painting manually you can paint everywhere as you want. There is an option to use the steepness/angle rules on the Vegetation Item to filter out instances from the paint brush but this is turned off by default.

    You do not need to bake any vegetation in order to start painting manually. Just create a persistent storage object and assign it.



    2. Rock collision detection is a bit tricky. They are sometimes large and iregular in shape.
    When spawning vegetation each cell is spawned in a separate thread. You can not use colliders to test, they do not exist at the time and it would be to slow.

    I have been experimenting a bit with different approaches that can be done fast. My current ide is to extend the collision grid I use for tree collision detection and "stamp" in a pre generated 2D profile of each rock as they are spawned, then sample this grid for the next rock spawning etc. Still in prototype stage.

    You said masking did not work for you but I will explain the process anyway for others.

    a solution I have been using is creating a mask of the rocks and assigning those to trees and other vegetation.

    To do this I would

    • Bake out the rocks temporary to the scene using the scene vegetation baker.
    • Then generate an obstacle mask from the rock colliders, adding any padding you want.
      https://www.awesometech.no/index.php/obstacle-mask-creator/
    • Then removed the temporary rocks
    • and finally use the generated mask as an exclusion mask for trees and other vegetation by addign this as a texture mask and adding texture mask exclude rules.
    Lennart
     
    mattis89 likes this.
  12. rasto61

    rasto61

    Joined:
    Nov 1, 2015
    Posts:
    352
    @LennartJohansen the bug when removing baked vegetation but billboards not being removed is there in 1.4. Please check pm.
     
  13. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi. I will do the fix when I am back in the office tomorrow. The API call just needs to find the correct billboard cell and clear the cache.

    Lennart
     
  14. daschatten

    daschatten

    Joined:
    Jul 16, 2015
    Posts:
    208
    Hey @LennartJohansen,

    i'm investigating some cpu spikes and noticed that some of them are related to vegetation studio:

    1. BillboardSystem.LateUpdate()
      GenerateBillboardCell() is the culprit here. It's curious because i have only grass and plants, no trees. I removed the billboard component and this problem is gone :)
      vegetationstudio-billboardsystem.png
    2. VegetationSystem.Update():
      See screenshot. Can this be avoided?
      vegetationstudio-updatevegetation.png
    Using unity 2017.4.9 and VS 1.4.0.0.

    Thanks,
    Florian
     
  15. LennartJohansen

    LennartJohansen

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

    First you should try to profile from a standalone build. Vegetation Spawning is faster there. It uses a c++ dll for the heavy math.

    What you see here is run-time spawning ov vegetation cells. Multi threaded load vegetation happens when you have more than 1 cell to load. Each cell will be done in a separate thread.

    Having the vegetation baked to a persistent storage will make this much faster since the instances are ready.

    Most of the time used in the first image was the garbage collector kicking in. This could happen anywhere in code but is more likely to happen where you allocate some memory on the heap.

    Depending on your setup? one, multiple terrains etc it there is some pre-loading options for billboards.

    If you join the vegetation studio discord server and message me we can see what fits your setup. text chat is easier to debug with.

    Lennart
     
  16. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    hello! where can I assign the second camera for VS to render thrue? ... Im messing around with a fps player and a boat.. how to do this I know... but the problem is the boat need a camera wich gets activated when you enter the boat.. and player camera goes inactive....
     
  17. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Call the SetCamera function with the camera you want to switch to.

    Code (csharp):
    1.  
    2. VegetationStudioManager.SetCamera(newCamera);
    3.  
    Lennart
     
  18. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151

    Thanks! Excellent! will it be a problem if I have that camera active at the same time as the player?
     
  19. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Calling SetCamera will switch to the new camera. You need to call it again if you need to change back.
     
  20. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Yes okay, I get this;
    Severity Code Description Project File Line Suppression State
    Error CS0103 The name 'VegetationStudioManager' does not exist in the current context Assembly-CSharp D:\Unity Projects\Fishermans Tale\Assets\My Stuff\Scripts\EnterVehicle.cs 31 Active


    I did at the top of the script using "and your brand" ; .. still error .. what component need I to call?
     
  21. JonDadley

    JonDadley

    Joined:
    Sep 2, 2013
    Posts:
    139
    I'm having trouble adding Indirect Instancing support to an Amplify Shader Editor shader. I followed the instructions on the website: I copied VS_indirect.gcinc into the same folder as the shader, I added the includes and pragmas in the Shader Editor exactly as shown on the website but whenever I add the include line for the gcinc, I get these log errors and the shader fails to compile:



    Any ideas what might cause it? On Unity 2018.1.5f1.
     
  22. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    The SetCamera function is a static public function on the VegetationStudioManager class. If you have the right include on the top it should work.

    Lennart
     
  23. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi. I think they changed the UI on the amplify editor a bit but it should work. If you send me a copy of your shader in a pm I can try to open it. Something else seems strange. all the other cginc files are not used by the VS_Indirect file.
    Maybe you need to include the name in "" or not? I do not have Amplify in front of me now.

    Lennart
     
  24. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Can you send me a PM how it should look? I very i have it right but still errror?
     
  25. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi. I made a sample script that should change to cameraBoat if you press 1 and CameraPlayer if you press 2 key.
    Did not test it, but it should work fine.

    Code (csharp):
    1.  
    2.  
    3. using AwesomeTechnologies.VegetationStudio;
    4. using UnityEngine;
    5.  
    6. public class Testscript : MonoBehaviour
    7. {
    8.     public Camera CameraBoat;
    9.     public Camera CameraPlayer;
    10.  
    11.     void Update()
    12.     {
    13.         if (Input.GetKeyDown(KeyCode.Alpha1))
    14.         {
    15.             VegetationStudioManager.SetCamera(CameraBoat);
    16.         }
    17.  
    18.         if (Input.GetKeyDown(KeyCode.Alpha2))
    19.         {
    20.             VegetationStudioManager.SetCamera(CameraPlayer);
    21.         }
    22.     }
    23. }
    24.  
    25.  
    Lennart
     
  26. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151

    Thanks alot!! I see what I did wrong =) Awesome support !
     
  27. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
     
  28. Aubrey-Falconer

    Aubrey-Falconer

    Joined:
    Feb 13, 2008
    Posts:
    438
    Hi @LennartJohansen! Apologies if this has already been covered, but I haven't found any mention in the docs or by searching this forum thread. I'm using Vegetation Studio with the "Auto Select Camera" checkbox activated, and everything is working as expected during normal scene rendering through the main camera.

    When I use a script to capture in-game screenshots, however, the vegetation isn't shown in the captured screenshots. Here is the screenshot capture script I am using:

    Code (CSharp):
    1. public void Capture()
    2.     {
    3.         _playSound();
    4.  
    5.         var fileName = OutputDirectory + "Core";
    6.         var resWidth = Screen.width;
    7.         var resHeight = Screen.height;
    8.         var scale = (resWidth > 3000 ? 1 : 2);
    9.         var camera = Camera.main;
    10.         var tFormat = TextureFormat.RGB24;
    11.  
    12.         string date = System.DateTime.Now.ToString();
    13.         date = "_" + date.Replace("/", "-");
    14.         date = date.Replace(" ", "_");
    15.         date = date.Replace("\\", "_");
    16.         date = date.Replace(":", "-");
    17.         fileName += date;
    18.         fileName += "_" + Random.Range(0, 1000);
    19.         fileName += ".jpg";
    20.         fileName = fileName.Replace("&", "_");
    21.  
    22.         int resWidthN = resWidth * scale;
    23.         int resHeightN = resHeight * scale;
    24.  
    25.         RenderTexture rt = new RenderTexture(resWidthN, resHeightN, 24);
    26.         camera.targetTexture = rt;
    27.         camera.Render();
    28.         RenderTexture.active = rt;
    29.  
    30.         var screenShot = new Texture2D(resWidthN, resHeightN, tFormat, false);
    31.         screenShot.ReadPixels(new Rect(0, 0, resWidthN, resHeightN), 0, 0);
    32.         camera.targetTexture = null;
    33.         RenderTexture.active = null;
    34.  
    35.         byte[] bytes = screenShot.EncodeToJPG();
    36.  
    37.         System.IO.File.WriteAllBytes(fileName, bytes);
    38.  
    39.         Debug.Log("ScreenShot :: New shot saved to " + fileName);
    40.     }
    As you can see, this script renders a frame on the main camera. What should I do to include VS vegetation in this rendered frame?
     
  29. LennartJohansen

    LennartJohansen

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

    My guess is that you try to do this to early in the frame. To make sure you get vegetation it has to be done after the VegetationSystem and BillboardSystem renders vegetation.

    Do your Capture call in LateUpdate and Set your script execution order to 110+ in order to process after all the Vegetation Studio classes.

    Image 514.png

    Lennart
     
    Aubrey-Falconer likes this.
  30. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Is this still possibly coming at some point, to VS and/or VSP?
     
  31. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    This is working now in the VS Pro beta.

    There is a new 3rd party shader controller system that allows you to create a c# class that implements an interface. This contoller class can expose settings to the UI that serializes to the VegetationPackage.

    It will also get an event when a material needs updating. This event gets the EnvironmentSettings class in Vegetation Studio Pro as a parameter.
    Here shaders can do their custom code and apply snow and wetness to the materials.

    If you look at the snow materials from the Mountain Trees package (NatureManufacture) in the VS Pro beta you can see this in use. They are linked to the global setting on the environment tab of the VegetationSystem component.

    Lennart
     
    mattis89 and Baldinoboy like this.
  32. Aubrey-Falconer

    Aubrey-Falconer

    Joined:
    Feb 13, 2008
    Posts:
    438
    Thanks! Customizing the script execution order did the trick.
     
  33. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Awesome!
     
  34. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    Hi,

    how does wind work in VS and how can I control which part of custom mesh is affected by it? Is it by vertex colors maybe?
     
  35. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    That depends on what shader you use. The included grass shader uses vertex colors. Phase and bend is baked in the vertex colors.

    Lennart
     
  36. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    "Do your Capture call in LateUpdate and Set your script execution order to 110+ in order to process after all the Vegetation Studio classes."

    Is this something I need to do in LateUpdate too when I switch render cameras from player > boat, boat > player... ?
     
  37. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    Can you give me some more details?
    1. which channel represents what value?
    2. what is a "phase"? I don't really see any difference with "include phase" turned on and off in grass patch generator.
    3. is VS grass shader the same (in terms of using wind vertex colors) as tree creator leaves?
     
  38. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    if you look in the AGrass.Shader you will find the colors defined

    #define AG_PHASE_SHIFT v.color.g
    #define AG_BEND_FORCE v.color.b

    Phase in green color, bend in blue.

    The phase is used if you have multiple branches, planes etc to get them to move out of sync with each other. Not to have one entire plant move equal.

    I am not sure what vertex color the tree creator uses. for most shaders the wind speed is read as a global variable and not touched by Vegetation Studio.

    Lennart
     
    DrInternet likes this.
  39. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    No. You do not have to do that. Your camera creates its own render events.

    Lennart
     
    mattis89 likes this.
  40. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151

    Works good , like it when you cant see the vegetation disappering... BUT theres like a second of delay from switching cams... I have the code like at the top of everything like this ;

    if (Input.GetKey(KeyCode.E))
    {


    VegetationStudioManager.SetCamera(CameraBoat);
    player.transform.parent = gameObject.transform;
    vehicleScript.enabled = true;
    player.SetActive(false);
    inVehicle = true;
    }

    is there any diference where i put the line, so the delay disappears or is it only like this in editor?
     
  41. AngelBeatsZzz

    AngelBeatsZzz

    Joined:
    Nov 24, 2017
    Posts:
    239
    I received this error When I use MapMagic and VegetationStudio.And sometimes it will crash Unity.

    How can I fix it?
     

    Attached Files:

  42. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi. I have been trying to debug a bit and it seems like it is related to MapMagic preparing terrains on a different thread. For terrains not visible yet they do not clear properly when destroyed.

    The change need to be done in the MapMagic code. I will talk to Denis and see if we find a solution.

    Lennart
     
    Hexalted and ftejada like this.
  43. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    It does need to load all the vegetation for the new camera view. Is it faster if you switch multiple times in a row?

    Lennart
     
  44. AngelBeatsZzz

    AngelBeatsZzz

    Joined:
    Nov 24, 2017
    Posts:
    239
    Understand,thanks for reply.
     
  45. Genebris

    Genebris

    Joined:
    Mar 18, 2013
    Posts:
    144
    Does anybody else have a problem where tree creator trees don't have self-shadows?

    Tree on the left is added to the scene manually and trees on the right are from VS.
     
  46. GamePyro-com

    GamePyro-com

    Joined:
    Jul 28, 2018
    Posts:
    197
    Hello

    I have some problem with Vegetations Studio

    I have the Mountain Trees from Naturemanufacturer but the Billboard are much brighter then the trees self i tryed change billbord settings not work. also have other treesfrom Tree Bundle pack but same problem :(


    Also the Vegetation Studio grass is very CPU GPU intensive if make distance view at maximum without it it looks bad :( but fps below 5 on a GTX 1080:


    And how can make the Trees also use the Wind ?

    And collider is not auto build at Vergetation Studio ?



    And can i make use of sattelite image to set where trees and where grass should be spawn ?


    And at EasyRoads3D and R.A.M River Auto MAterial also not work Grass goes over river and roads so i added touchbend collider and mesh but also looks bad . How can fix that ?





    Regrads
     
  47. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi. Try to switch to one of the other tree creator shaders. Some of them have some problem with instancing.
    Is it the same on forward and deferred?

    Lennart
     
  48. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi. I will send you a private message and help you debug. Something seems to be making a problem in your scene. That is a powerfull card you should get good results.

    Wind is controlled by the shader. If you use NatureManufacture trees i think there is a wind component you need to add to a GameObject in the scene. Also a WindZone

    Vegetation Studio has a collider system that creates colliders for trees/rocks when close to the camera. You need to enable the colliders on each vegetation Item(tree/rock)

    Look here for more info on the collider system.

    This depends a bit on the satellite image. If you have a satelite image that matches the terrain size you can add it as a texture mask. Use the color mask type and make include/exclude spawning rules based on the terrain color.

    Some satelite images like landsat 7 also have an infrared band that is nice for detecting vegetation areas. If you add this to a RGBA mask and use the infrared channel as a rule it could give nice coverage.

    There is a Vegetation Masking system that is good for creating roads or areas you want to mask out vegetation.

    Easy Roads has integration with Vegetation Studio that creates VegetationMaskLine components automatic when you create roads. You can enable this in EasyRoads.

    Look at the documentation for the VegetationMaskArea and VegetationMaskLine

    Lennart
     
  49. GamePyro-com

    GamePyro-com

    Joined:
    Jul 28, 2018
    Posts:
    197
    Thank you will try

    yes i set the colliders but not work.

    At easyroad i set also not work

    At the R.A.M from naturemanufactor also stand vegetation studio compatible.


    regards
     
  50. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Check with the Easy Roads forum. But i think you will have to enable it before you create the roads.

    Colliders are by default hidden in the hierarchy. There is a setting on the ColliderSystem if you want to see them.

    I think R.A.M has a setting to create VegetationAreaMasks when you create a river, but I have not used it. Look in the documentation.

    If you could join the discord server and send me a message there I can help you to look at your collider configuration. Easier to debug on a text chat.

    Lennart
     
Thread Status:
Not open for further replies.