Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

[Released] Advanced Terrain Grass

Discussion in 'Assets and Asset Store' started by larsbertram1, Sep 11, 2017.

  1. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    no, it does not afaik.
     
  2. varganorbert222

    varganorbert222

    Joined:
    Aug 9, 2015
    Posts:
    4
    Welcome to the developer!

    I recently bought the package because I saw it works with URP pipeline, and YES. WORKING.
    I modified the shader so that the grass would pick up the color of the terrain according to a certain texture.
    Can i expect this feature to be available with official support?
    I attached pictures of the result and the modify of the shader.

    Personally, I'd love it because I think it's a nice effect and I need it.

    More pleasant development!

    colorgrass.png 1.JPG 2.JPG 3.JPG 4.JPG
     
    Last edited: May 27, 2020
    kepesh, pixelR, GCatz and 2 others like this.
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    nice!
    but i am not sure if i will support this because it gets a bit complicated in case you have multiple terrains.
    also just replacing albedo with the sample from the color or pigment map might be too simple for most cases.
     
  4. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,455
    That color grass from terrain is amazing!
     
  5. varganorbert222

    varganorbert222

    Joined:
    Aug 9, 2015
    Posts:
    4
    I got a little sad, but that's okay. I'm going to do a Manager class that does this automatically. In my case, that's enough. My question is, shadergraph editing is possible? Thank you for your answer and support!
     
  6. varganorbert222

    varganorbert222

    Joined:
    Aug 9, 2015
    Posts:
    4
    Thanks, this is a simple workaround. :)
     
    Lars-Steenhoff likes this.
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    unfortunately shader graph does not support the functionality to needed by the shader.
     
  8. Natoff

    Natoff

    Joined:
    Feb 24, 2017
    Posts:
    14
    Hi

    I would like to know, Can I increse speed of grass bending or something that trigger bending faster. In following clip you will see a little delay from grass bending. If I can plese advice me. Thank you

     
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    it depends on the position of the a) displacement texture or b) particle system you use.
    it looks as if they are too late...
     
  10. Natoff

    Natoff

    Joined:
    Feb 24, 2017
    Posts:
    14
    I don't know what I did wrong. But I also got the same delay in Grass Displacement RenderFeature ATG Demo as attached clip.

     
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    the particle system might need to fade in particles faster.
     
  12. Natoff

    Natoff

    Joined:
    Feb 24, 2017
    Posts:
    14
    Thank you. I solved problem. I had modified smoothfollow.cs to update particle tail position faster and rotation update. Following is the result

    May I have a suggestion. Could you add bending speed or displacement speed to the shader? I think it will look nicer if it allow to adjust time that grass need restore to normal state.

     
    Last edited: Jun 4, 2020
    andreiagmu likes this.
  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    this solely depends on the lifetime of your particles:)
     
    andreiagmu likes this.
  14. Natoff

    Natoff

    Joined:
    Feb 24, 2017
    Posts:
    14
    It works. Thank you. :D:D:D
     
    andreiagmu likes this.
  15. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,209
    Do you have any reports of success using this with procedural terrains in runtime? Or a workflow to improve that? I'm just instantiating the "full terrain" in the demo and it's got a 750ms spike for GrassManager.Init().
     
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    sorry, but this is nothing i have ever looked into.
    assuming that you use map magic: it should have its own data structure for height and grass density.
    so instead of grabbing that i would get it directly from map magic.
    this however means that you have to rewrite the entire init() function...
     
  17. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,209
    I don't use 3rd party tools for generation. I'll look into threading the init() function. Would be a nice feature for the future.
     
  18. Xentar

    Xentar

    Joined:
    Apr 8, 2011
    Posts:
    23
    Hey, Lars.
    Right now i'm playing around with an idea, and i'm using a lot of your assets (colormap ultra terrain, lux, atg and afs), but working on default pipeline. Probably someday going to move to URP, but for now, composing all the old way.
    Got ATG because i saw the touch bending feature. Well, you must figured out what i found later, jejejeje Anyway, still using because the results are really good.

    Now, i wanted to give a try and add some kind of touch-bending. Found this: https://github.com/Elringus/GrassBending
    And decided to give it a try to "blend" the "_BendData" on the grass shader of ATG, but i just can't figure where or how. I'm far from shader expert... neither the best programmer, so decided to ask:
    You think is possible to add this solution or there is no way to translate it?

    *Edit: Figured a way, no the solution of the link above, but its work ""fine"". And is kinda easy...
     
    Last edited: Jun 27, 2020
  19. Monil

    Monil

    Joined:
    Apr 24, 2012
    Posts:
    100
    @Xentar , @larsbertram1

    Hi,
    I also still use the default pipeline and I am interested in a performing system for bending the grass and the only thing that stopped me from buying ATG is that it is supported only on URP, I ask if I can have any advice on how to implement it or if the author of ATG will implement it in a relatively short future.
     
  20. ash4640

    ash4640

    Joined:
    Jan 19, 2018
    Posts:
    66
    Hi just curious is ATG
    - a shader system only for grass or a complete rendering system too
    - if a rendering system how different from Nature Renderer (any different features) as I own Nature Renderer already
    - if rendering system for grass than can it render grass? as in textures? or just prefabs
    btw have your water shaders both Lux water and Lux urp beautiful shaders
     
    Last edited: Jul 21, 2020
  21. SuperSonic68

    SuperSonic68

    Joined:
    Feb 8, 2013
    Posts:
    4
    Hello! I'm attempting to use ATG to replace my current grass system. It's a VR experience, so I have large grass objects at a very low Detail Density to reduce draw calls. In the original Terrain, it was 0.01 and it worked fine. However, with ATG, I am unable to have grass at ANY value except for 1. Anything else and it simply refuses to render.
    0.01, 0.5, 0.9999, nothing. ONLY the maximum density seems to actually render the grass.

    Please advise.
     
  22. dead_pixel_society

    dead_pixel_society

    Joined:
    Oct 1, 2013
    Posts:
    8
    Hello.
    Loving atg, great work.

    I did a build to ios, very impressive! Unfortunately, the build grass has a grid distribution which I assume related to the cells, but is not present this way in the editor.
    Any thoughts on how to address this?
    (URP)

    95B201B9-CD6F-41D9-8E56-92DA8671B052.jpeg
     
    Last edited: Jul 20, 2020
  23. ritorct

    ritorct

    Joined:
    Jul 10, 2017
    Posts:
    3
    Hi, demo scene with URP error. grass not showing when i play in editor & get this error

    NullReferenceException: Object reference not set to an instance of an object
    AdvancedTerrainGrass.GrassManager.Init () (at Assets/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:1070)

    NullReferenceException: Object reference not set to an instance of an object
    AdvancedTerrainGrass.GrassManager.DrawGrass () (at Assets/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:1352)
    AdvancedTerrainGrass.GrassManager.LateUpdate () (at Assets/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:358)

    how to solf it.?
    unity 2019.3.1
    URP 7.3.1

    upload_2020-8-11_0-27-20.png
     
  24. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    i like it: kronnect use the atg URP demo to showcase his new dynamic fog and mist package for URP. altho the lighting on the grass is a bit off...

     
  25. AaronVB

    AaronVB

    Joined:
    Oct 14, 2020
    Posts:
    1
    Hey! First of all: great work. Second; everytime i want to add a custom rock model prototype i get the following error:

    AdvancedTerrainGrass.GrassManagerEditor.OnInspectorGUI () (at Assets/_AdvancedTerrainGrass/_Scripts/Editor/GrassManagerEditor.cs:583)
    UnityEditor.UIElements.InspectorElement+<>c__DisplayClass58_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <fe25ae58492f48c395e59c49713b9c5c>:0)
    UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)


    can you help? i am using a .obj model with only one solid color material
     
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    hmm,that does not tell me anything right now. will have to look into it.
     
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    ah! the solid color! the grass manager editor looks for the texture assigned to the model to get a path where to store the new material. so only having a solid color will most likely break it.
    so instead of the solid color yo might just add a 4x4px solid color texture.
     
  28. gewl

    gewl

    Joined:
    May 19, 2016
    Posts:
    95
    Hi,
    I'm having an issue that I've seen a couple others mention in this thread, but I haven't seen a fix posted: On compile my log gets spammed with over a thousand warnings reading:

    I also get a handful of the following errors thrown:

    Neither seems to actually break anything, but I'd love to clear my log out. Does anyone know how I could resolve this?

    Also, am I missing a way to disable the Max Bucket Density/Max Instances logging from GrassManager?
     
    Last edited: Nov 2, 2020
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    you may try to add the grass manager to a custom "Assembly Definition".
    you will have to comment this in the code, sorry.
     
  30. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    i totally missed this, sorry. android also used to produce patterns due to the custom random function i use.
    so android use a special random instead. you may try to use this on ios as well. unfortunately this needs you to edit the grass manager script...
     
  31. rostik1975

    rostik1975

    Joined:
    May 14, 2015
    Posts:
    44
    Hi,
    Is it possible to implement a touch bend feature for default pipeline (ATG v. 1.091, Unity v. 5.4.1f1)?


    The goal is to somehow hide the grass behind the boat:
    atg_grass_bending.jpg
    Could you please point me on a right direction?
    Should I update Terrain grass texture with SetPixel(), temporarily cleaning grass on a map according to boat x,z position ? I think this is quite expensive if I use it in Update().
    How is this feature implemented in URP?
    Thank you.
     
  32. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
  33. rostik1975

    rostik1975

    Joined:
    May 14, 2015
    Posts:
    44
    Thank you very much, I have implemented the mentioned solution https://forum.unity.com/threads/released-advanced-terrain-grass.494865/page-4#post-3333972 with the same shader modifications, but without using add. camera. The script attached to the boat is
    Code (CSharp):
    1. using UnityEngine;
    2. public class TouchBend : MonoBehaviour
    3. {
    4.     public Texture2D boatMap;
    5.  
    6.     private void Start()
    7.     {
    8.         Shader.SetGlobalTexture("_touchrtx", boatMap);
    9.         Shader.SetGlobalFloat("_camsize", 90f);
    10.     }
    11.    
    12.     private void Update()
    13.     {
    14.         Shader.SetGlobalFloat("_camposx", transform.position.x);
    15.         Shader.SetGlobalFloat("_camposz", transform.position.z);
    16.     }
    17. }
    and 'baked' Texture2D, to avoid performance issues:
    touchBendMap.png
     
    camta005 likes this.
  34. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    i play mode the grass manager will draw the grass. in edit mode grass is just built in grass on the terrain.

    1. so lets check wind first:
    drag one of the used/provided grass prefabs into your scene. if it just vanishes, wind si not set up properly. most likely the wind prefab is just missing.

    2. check your camera: is it tagged as "MainCamera"?

    3. go to the console and look for any errors.

    4. go to the grass manager and turn in its debug features. you should activate "gizmos" in the upper right corner of the game view.
     
  35. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    479
    I am having difficulty getting the foliage to show up on my terrain. I have setup the system according to the directions and went through the Troubleshooting section on "Grass Does not show up at all". I have made a duplicate of the Full Demo camera and copied the Grass Manager from the Full Demo mode and placed it on my terrain. I've only painted one plant from this Asset.
    Here is a video of what I'm seeing:


    Any help would be great.
     
  36. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    479
    I suppose it has to do with Bucket Density & Instances per Layer Cell although I did specify Layer to merge with = 1 and checked Soft Merge just like the demo terrain.
     
  37. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    479
    Okay so I removed the "Layer to merge with" and some of my grasses are coming through. One strange thing though, when I paint Grass Daisies in edit mode, they show up. But in play mode I get dry grass!?
    The Grass Manager does have the Grass Daisy setup as its prototype.
     
  38. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    479
    Does this handle dynamic "MainCamera" spaws? I have nothing showing up again but I'm guessing it is because now my MainCamera is being instantiated with my Player on scene start.

    Reverting back to a static main camera I have lost everything. Now I see the following in the console.

    Code (CSharp):
    1. Assertion failed on expression: 'triangleCount == totalTriangleCount'
    2. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    3.  
    4.  
    5. Assertion failed on expression: 'vertexCount == totalVertexCount'
    6. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    7.  
     
  39. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    the grass will be rendered using the given material. if this uses texture arrays and you have set any layer to merge with or random then you will get something you may not expect.
    yes. you just have to make sure that your camera is tagged properly.
     
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    and do not use grass billboards!
     
  41. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    479
    Well I got rid of billboards and still nothing. Another error in the console though:

    Code (CSharp):
    1. IndexOutOfRangeException: Index was outside the bounds of the array.
    2. AdvancedTerrainGrass.GrassManager.DrawGrass () (at Assets/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:1509)
    3. AdvancedTerrainGrass.GrassManager.LateUpdate () (at Assets/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:358)
    4.  
    If I have Burst Init on I get
    Code (CSharp):
    1. IndexOutOfRangeException: Index was outside the bounds of the array.
    2. AdvancedTerrainGrass.GrassManager.BurstInit () (at Assets/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:1186)
    3. AdvancedTerrainGrass.GrassManager.Init () (at Assets/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:1140)
    4.  
     
  42. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    i guess you wil have to setup your terrain again. try update prototypes.
     
  43. Beral

    Beral

    Joined:
    Feb 9, 2018
    Posts:
    7
    Hi,

    I have problems with the editor tools of this asset, it seems that they consume a lot of RAM in the Unity Editor and if I add the grass manager to multiple terrains (16) I get out of memory errors like this one: D3D11: Failed to create render texture primary RTV (error 0x887c0003)

    I have 32 GB of ram.

    I checked the Windows RAM's consumption and when I have the managers in the terrains, the consumption is very high. When I remove the Grass Managers from the terrains the memory problem is solved and I don't get the D3D11 error anymore.

    So bassically I cannot use this kind of grass if I have a big map (multiple terrains).
     
  44. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    16 terrains is out of scope. max would be 4: you do not have to mange the grass manager more than 4 terrains at any given moment. in order to decrease memory consumption use "saved terrain data".
     
  45. lilacsky824

    lilacsky824

    Joined:
    May 19, 2018
    Posts:
    164
    Can I use same mesh of grass with Lux URP essentials's grass shader and Advanced Terrain Grass's shader?
    Or I need to swizzle vertex color's channels?
     
  46. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    both let you choose between a and be storing the bend amount. so you should be fine.
     
    lilacsky824 likes this.
  47. FaberVi

    FaberVi

    Joined:
    Nov 11, 2014
    Posts:
    145
    Hi, I'm using the plugin in a project for Oculus Quest 2, in the editor everything works correctly but in the build the wind makes the grass "slip" on the ground (as well as seeing it about 2-3 centimeters off the ground). How can I solve these problems?
     
  48. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    @larsbertram1, I have a question regarding garbage collection. I've been optimizing GC allocations in my project. But at some point I've noticed not trivial issue. When I stand still, GC allocations were at an expected rate, but as soon as I've started running my mono memory size immediately started to grow at a high rate. Of course this forced garbage collection to trigger more often than I like. This is how it looks.


    Profiler showed nothing, but as soon as I've disabled Grass Manager, issue was gone. So it became clear, what is forcing Mono memory to grow so fast (when I'm moving). Is this normal? Can I do something about it?
     
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    i remember another customer having a similar problem. it was caused by unity stripping out vertex colors from the meshes at build time.
    the easiest way to check this is to disable or modify the vertex optimization in the player settings so unity will not optimize or strip vertex colors.
    but of course disabling mesh optimizations is not the best idea... so you can also try to simply add all your grass meshes with the atg grass material attached somewhere in your scene. this should make uniyt aware of these meshes using a shader which needs vertex colors so it does not strip these.
     
    FaberVi likes this.
  50. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    the grass manager itself should not produce garbage during runtime or allocate new ressources. the worker thread does as it creates the arrays. but this gets handled on the worker thread and doesn't slow down main thread.

    using the included demo scene and graphy i can nort reproduce your result: here the numbers are pretty stable!
    allocated: around 127mb, mono: around 28mb.
    so i assume that either you are using an "insane" Cache Distance so that created cells hardly ever get wiped out. or something else is going nuts in project.