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] Advanced Terrain Grass

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

  1. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    hmm, so it does not seem to be null.

    so replace:
    // Due to ExecuteInEditMode LayerToMergeWith might not be setup by the editor. So we will simply create and fill it
    if(LayerToMergeWith == null) {

    with:
    // Due to ExecuteInEditMode LayerToMergeWith might not be setup by the editor. So we will simply create and fill it
    bool updateLayerToMergeWith = false;
    if(LayerToMergeWith == null) {
    updateLayerToMergeWith = true;
    }
    else if (LayerToMergeWith.length != OrigNumberOfLayers.Length) {
    updateLayerToMergeWith = true;
    }
    if(updateLayerToMergeWith) {
     
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    terrains themselves already are drawn in chunks (if they are not only a single flat plane) and culled properly. so i do not really see the need to use that many terrains... unless i miss something here.
    5x5 128x128m terrains should be easy to be replaced with one 640x640m terrain.
     
  3. Muravu

    Muravu

    Joined:
    Nov 30, 2014
    Posts:
    53
    Do you plan on implementing a version of the asset that gets all the terrains in the scene and adjusts the rendering of the grass in one place rather than having to adjust the same settings on 5-10 terrains that I have to use because I'm making a open world game.? At the moment the grass doesn't render for me at all when i hit play.
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    what is wrong?
     
  5. Muravu

    Muravu

    Joined:
    Nov 30, 2014
    Posts:
    53
    I assume It's tied to the number of terrains we use for the level. I will try to merge the terrains somehow and then I will try it again.

    Just to clarify It worked once I merged the many terrains into one.
     
    Last edited: Jul 12, 2019
  6. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    Hi, there! How can I make grass interact with player? Is there a way to mass place grass?
     
  7. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    Hey, there!

    Can you make a video tutorial on how this is done? I don't know how to code. I'm just a designer!
     
  8. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    Interactive bending grass is my top priority
     
    Last edited: Jul 26, 2019
  9. LumaPxxx

    LumaPxxx

    Joined:
    Oct 3, 2010
    Posts:
    340
    Sorry,i didnt touch unity for a long time.
    but,i know vegetation studio could do what you want and atg support it too.
     
    Sam512 likes this.
  10. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    Vegetation Studio can make grass interact with player and support ATG, right?
     
  11. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    Vegetation Studio or Pro one that has that feature? Please bro can you tell? I can't spend money carelessly
     
  12. Muravu

    Muravu

    Joined:
    Nov 30, 2014
    Posts:
    53
    I have a problem where the grass just pops in. It's not tied to player speed as I'm doing it really slowly, and it happens only on one part of the level. I deactivated all object there only the terrain and grass are present and the problem still persists. Could you give me some advice on where to look for possible problems at all? What could be the problem?

    I made a short video, you can view it here:

    https://drive.google.com/file/d/1Pgj-oX3t1xKtfFel38Z5DcwnYrLfu36u/view?usp=sharing

    I removed all the other object, it's just the terrain and the grass, I do have more than one terrain with grass manager in the scene, but even when I disable all but one terrain with one grass manager I get the problem. I tried to change up most of the settings on the grass manager by this point but I haven't found anything that helps.
     
    Last edited: Jul 30, 2019
  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    atg does not ship with any touch bending solution, sorry.
    you may however look through this thread and contact the member that implemented one.
     
  14. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    I have Vegetation Studio. How can I can make it work together?
     
  15. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    if vs renders the grass just assign the atg shaders to your prefabs. vs will pick them up and use the atg shaders when rendering grass.
     
  16. Muravu

    Muravu

    Joined:
    Nov 30, 2014
    Posts:
    53
    Could you please help me out? I made a post a few days ago. I even attached a video.
     
  17. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    sorry, i have missed your post.

    do your camera use occlusion culling? it looks like a problem with the culling spheres (although you have checked "ignore visibility").
    try to disable "occlusion culling" on the camera or rebake occlusion.

    btw.: as you are using compute a cell size of 4x4m is not very efficient. when using compute i recommend to use pretty large cell sizes like 16x16 or even 64x64m. the compute shader will cull invisible instances based on the camera frustum.
     
  18. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    I added grass manager to terrain and nothing worked. And I added grass manager to VS manager and grass dissapeared
     
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    you do not need the grass manager when you use vs. you only use the atg shader.
     
  20. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    And assign it to what? I assign to everything and nothing work
     
  21. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    I'm new to Unity. And I need grass bending solution. With your shader it look so beautiful. How can I create ATG shader. I can't find one, only grass manager
     
  22. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    It appears to look like that, but why is it not still bending?
     

    Attached Files:

  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    you do not create an atg shader!
    you create a material. then assign the atg grass shader.
    then assign this material to the prefab you use inside vs as grass model.
     
  24. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    Hey, It worked now! But your shader still can't touch bending. Is there any option that make your grass system touch bend? I asked VS dev, they said your system doesnt support VS touch bendind perhaps
     
  25. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    it does. you have to activate the option in the material inspector tho.
     
  26. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    Which one?
     
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    the atg material you use on the grass?!
     
  28. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
  29. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    That one?
     
  30. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    I checked Normal buffer and it become black
     
  31. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
  32. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    wrong shader. vs does not support normal buffers.
     
  33. oceanquigley

    oceanquigley

    Joined:
    Apr 20, 2018
    Posts:
    7
    Hello,
    Just got and am playing with the asset, having loaded it into a new project - and in the demo scenes the grass is all pink (I'm on 2018.3). Any advice?

    https://imgur.com/a/dn2XWmx
     
  34. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    most likely your camera is set to deferred – but you haven't assigned the atg deferred lighting and reflection shaders...
    please have a look in the docs:

    Deferred Rendering
    In order to implement deferred translucent lighting and physically inspired specular reflections ATG ships with its own deferred light and deferred reflection shaders.
    So in case your camera uses deferred rendering you have to assign the ATG deferred shaders in Edit -> Project Settings -> Graphics:
    • Under the Built-in shader settings change Deferred to custom, then assign the ATG_Internal-DeferredShading shader.
    • Also change Deferred Reflections to Custom and assign the ATG_Internal-DeferredReflections shader.
     
    oceanquigley likes this.
  35. oceanquigley

    oceanquigley

    Joined:
    Apr 20, 2018
    Posts:
    7
    Thanks! That's all there was to it.


     
  36. SRGeodan

    SRGeodan

    Joined:
    Oct 16, 2014
    Posts:
    12
    I get IndexOutOfRangeException in GrassManager.Init() line: 868 when i go in play mode. Grass does not show up. (Index was outside the bounds of the array).
     
  37. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    could you please check the line?
    line 868 is: Shader.SetGlobalVector( ...
    which does not look up any array.
     
  38. SRGeodan

    SRGeodan

    Joined:
    Oct 16, 2014
    Posts:
    12
    Fail.PNG

    Edit: I did not comment the 2nd part of the line, commented code was already there.
     
  39. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    ah, sorry. i did not update the package...

    from an older post at the top of this page:

    so replace:
    // Due to ExecuteInEditMode LayerToMergeWith might not be setup by the editor. So we will simply create and fill it
    if(LayerToMergeWith == null) {

    with:
    // Due to ExecuteInEditMode LayerToMergeWith might not be setup by the editor. So we will simply create and fill it
    bool updateLayerToMergeWith = false;
    if(LayerToMergeWith == null) {
    updateLayerToMergeWith = true;
    }
    else if (LayerToMergeWith.length != OrigNumberOfLayers) {
    updateLayerToMergeWith = true;
    }
    if(updateLayerToMergeWith) {
     
    Last edited: Aug 7, 2019
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    could you please remove the file from your post!?
     
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
  42. SRGeodan

    SRGeodan

    Joined:
    Oct 16, 2014
    Posts:
    12
    I deleted the post.
    There is no line: if(LayerToMergeWith == null)
    also, OrigNumberOfLayers is not an array?
     
  43. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    sorry, i should have read my own posts.

    you have to navigate to line 867 which is:
    Code (CSharp):
    1. for (int i = 0; i < OrigNumberOfLayers; i++) {
    above this line you have to enter the new code which is:
    Code (CSharp):
    1. bool updateLayerToMergeWith = false;
    2. if(LayerToMergeWith == null) {
    3.     updateLayerToMergeWith = true;
    4. }
    5. else if (LayerToMergeWith.length != OrigNumberOfLayers) {
    6.     updateLayerToMergeWith = true;
    7. }
    8. if(updateLayerToMergeWith) {
    9.     LayerToMergeWith = new int[OrigNumberOfLayers];
    10.     for (int i = 0; i < OrigNumberOfLayers; i++) {
    11.         LayerToMergeWith[i] = 0;
    12.     }
    13. }
    14.  
    15. // here comes old line 867 and all the rest:
    16. for (int i = 0; i < OrigNumberOfLayers; i++) {
    please note: the 2nd code snippet also contains line 867!
     
    Last edited: Aug 7, 2019
  44. SRGeodan

    SRGeodan

    Joined:
    Oct 16, 2014
    Posts:
    12
    My code is different, but i Managed it.
    However, I now get a different out of bounds array exception.
     

    Attached Files:

  45. SRGeodan

    SRGeodan

    Joined:
    Oct 16, 2014
    Posts:
    12
    Here is more info.
     

    Attached Files:

  46. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    strange. now your v_mat array is not set up properly.
    can you switch to debug mode and see how it looks like?
    unfortunately i can not do more debugging right now but will have a look into the package as soon as possible.

    meanwhile you can try to remove and add the grassmanager script again, leaving "draw in edit mode' untouched and go straight to playmode.
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    right. i fixed the code snippets. there were written out of my head...
     
  48. SRGeodan

    SRGeodan

    Joined:
    Oct 16, 2014
    Posts:
    12
    I have even more exceptions.
    Can i get the updated package?
    The demo's work fine though. I generate the terrain from script not editor. The Grassmanager script is added at last, could this be the issue?
     
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    yes, that will cause the issue. most arrays (like v_mat or the mesh array) are filled by the inspector.
    so you will have to fill these within your script.
     
  50. SRGeodan

    SRGeodan

    Joined:
    Oct 16, 2014
    Posts:
    12
    I get the first exception already when I:
    1. create a new terrain.
    2. Add grass texture
    3. Draw grass
    4. Add GrassManager -> Exception

    Code (csharp):
    1.  
    2. IndexOutOfRangeException: Index was outside the bounds of the array.
    3. AdvancedTerrainGrass.GrassManager.Init () (at Assets/GeodanGo/3rdParty/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:870)
    4.  
    Note: Line is slightly different because I removed the previous not working patch code.

    If I first add the GrassManager, then add grass it works I do not get an inital exception.
    However, If I do this from script:
    1. Add grass manager
    2. Add grass prototypes
    3. UpdateGrass -> Exception and also in PlayMode -> exception.

    Driving me crazy..