Search Unity

[Released] Advanced Terrain Grass

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

  1. nu51313932

    nu51313932

    Joined:
    Oct 28, 2016
    Posts:
    59
    Is there a tutorial how to add my new grass with specular map?
     
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,212
    all there is you will find in the docs.
     
  3. nu51313932

    nu51313932

    Joined:
    Oct 28, 2016
    Posts:
    59
    oh thank you. I am a newbie
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,212
    :)
     
    nu51313932 likes this.
  5. nu51313932

    nu51313932

    Joined:
    Oct 28, 2016
    Posts:
    59
    I have my own grass manager script that control grass bending on collision. but some of your script overide it. Any idea how to solve it?


    I use the asset of my friend but If I can fix this problem I will buy my own license ^^
     
    Last edited: Apr 20, 2021
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,212
    nope. i do not know how you handle it at all :)
     
  7. lilacsky824

    lilacsky824

    Joined:
    May 19, 2018
    Posts:
    85
    Will have support for URP 11?:)
     
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,212
    there is already a package for urp 11!
    if you do not have it after updating, clean your download cache of the assest store and re download it.
     
  9. lilacsky824

    lilacsky824

    Joined:
    May 19, 2018
    Posts:
    85
    I only see URP 7.2 package, even on asset store's page's package content.:oops:
     
  10. lilacsky824

    lilacsky824

    Joined:
    May 19, 2018
    Posts:
    85
    So I can use Lux Essential's grass shader instead of ATG's urp shader?:p
     
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,212
    damn, wrong thread, sorry :)
    na, the lux urp grass shader does not support procedural instacing.
     
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,212
    it is coming!

    atgurp11.PNG
     
    Last edited: Apr 22, 2021
    lilacsky824 likes this.
  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,212
    shaders for urp 10 and urp 11 now are available.
     
    lilacsky824 likes this.
  14. lilacsky824

    lilacsky824

    Joined:
    May 19, 2018
    Posts:
    85
    I tried it.
    Looks good. :) image_003_00002021-04-28.jpg
     
    Jesper-Nielsen likes this.
  15. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,212
    fine. your screen shot looks good as well. maybe the grass is a bit dense? and the intersection with the rock breaks immersion :(
     
  16. lilacsky824

    lilacsky824

    Joined:
    May 19, 2018
    Posts:
    85
    Just for test.
    I am not decide where to paint grass yet.;)
     
  17. Jesper-Nielsen

    Jesper-Nielsen

    Joined:
    Nov 14, 2013
    Posts:
    73
    I tried out the ATG asset and it works pretty well for me, although it's not exactly plug and play. You actually have to RTFM but I'm happy to have a nice wind solution for details:)

    I have several shaders from you that support wind - the ATG shaders, some shaders from LUX URP as well as some trees in packs from another vendor that use CTI shaders. Are you planning to consolidate this or should I just attach the different wind scripts? (At the moment I'm not using wind with my CTI shaders because I think they're not updated too URP 11? I seem to be getting an error with bark so I'm using your Tree Creator bark shader instead / trying around different stuff for the meantime).

    Until now I've been using manually placed details with simplelit shaders, but I must say terrain grass performs a whole lot better. One thing that annoys me a lot in general with Unity terrain is that you can't change settings for details without losing all of your work - I really wish they would implement resampling for the details layers like they have for textures.

    Another thing that irritated me with Unity terrain was that it blended in vertex colors, making it unusable for some of the detail models I had. Your shaders use vertex colors for wind so I had to do something about it anyway and I wrote a small quick-and-dirty editor script that will make reasonable wind alpha for grass meshes:

    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEngine;
    3.  
    4. public class GrassVertexColors : MonoBehaviour
    5. {
    6.     /// <summary>
    7.     /// Lerps alpha from 0 for y at or below 0 to 1 at max y
    8.     /// </summary>
    9.     [MenuItem("Pipeline/Grass Mesh Colors")]
    10.     static void FixVertexColors()
    11.     {
    12.         GameObject curr = Selection.activeTransform.gameObject;
    13.         Debug.Log(curr.name);
    14.         string error;
    15.         if (curr == null || !curr.name.Contains("grassvertex"))//security feature
    16.         {
    17.             error = "No appropriate object selected.";
    18.             Debug.Log(error);
    19.             return;
    20.         }
    21.  
    22.         MeshFilter mf = curr.GetComponent<MeshFilter>();
    23.         var msh = mf.sharedMesh;
    24.         if (mf == null || mf.sharedMesh == null)
    25.         {
    26.             error = "No mesh on the object.";
    27.             Debug.Log(error);
    28.             return;
    29.         }
    30.  
    31.         float maxY = 0;
    32.         for (int i = 0; i < msh.vertexCount; i++)
    33.             maxY = Mathf.Max(maxY, msh.vertices[i].y);
    34.      
    35.         var colors = msh.colors;
    36.         for (int i = 0; i < msh.vertexCount; i++)
    37.         {
    38.             float y = Mathf.Max(msh.vertices[i].y, 0);
    39.             float a = Mathf.Lerp(0, 1, y / maxY);
    40.             colors[i] = new Color(1, 1, 1, a);
    41.  
    42.         }
    43.         msh.colors = colors;
    44.     }
    45. }
    Workflow for healthy/dry colors is a bit tricky to get right. The material healthy/dry colors are set to the colors from the terrain, but when working with several terrains that share the same detail, or different detail meshes sharing the same material you have to make sure to set them all to the same values, or it becomes unpredictable which value is actually used? I kinda wish the script had an option to not copy that data, so you could edit these values in the material and not have them be overwritten? When do these values get copied - only when you press update prototypes or also sometimes on other occasions?


    Could you give some recommendations on workflow with multiple terrains in the scene? Perhaps Manually enable/disable the managers for the terrains you aren't currently working with in edit mode, and then enabling/disabling via script at runtime as terrains enter the view in play mode?
     
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,212
    there should only be 2 scripts when using urp:
    - wind for grass and foliage which gets sampled from a render texture.
    - wind for trees which gets fed in as several floatx values.
    both scripts are driven by a unity wind zone.
    right now i have no plans to make trees listen to the render texture as well.

    there is an update for urp 11 - but it is difficult and time consuming to distribute it...


    you can check "freeze size and color" in th egrass manager. then it will not update the used atg material anymore. and you can use the same material on all of your terrains.
    i have no special recommendation. just use the way that best fits your needs.
     
    Jesper-Nielsen likes this.
  19. svfritz

    svfritz

    Joined:
    May 13, 2021
    Posts:
    2
    So I picked this up in the current bundle and I'm really interested in trying it out, but when I load up the demo scene in a blank URP project it's not rendering any grass, but is rendering some random pink geometry in the sky here and there. I've been through the documentation and tried all the obvious troubleshooting things listed there, but come up empty.




    In the end cells to init always reads as 0.
    The only error message I got in the console was:

    Shader error in 'AdvancedTerrainGrass/VegetationStudio/Grass Base Shader': Unexpected token ';'. Expected one of: ',' ')' at Assets/AdvancedTerrainGrass/Shaders/ATG Shaders/ATG Standard RP Shaders/Includes/VS_GrassInstancedIndirect_Vertex.cginc(80)

    On the assumption it was a simple typo I attempted to fix it and it made no difference; it wouldn't surprise me if there's something else wrong here since I am not particularly familiar with it and just hazarded a guess that would eliminate the console error. Original line:
    Code (CSharp):
    1.     wind.r = wind.r * (wind.g * 2.0f - 0.24376f; //  Not a "real" normal as we want to keep the base direction.
    'fix':
    Code (CSharp):
    1.     wind.r = wind.r * (wind.g * 2.0f - 0.24376f); //  Not a "real" normal as we want to keep the base direction.
    2.  
     
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,212
    hi there,
    you have to install the urp package. then open the urp demo called "02 Full Demo URP"!
    as shown on your screen shot you are in the demo scene for the built in render pipeline... the materials used by the grass and foliage here use standard deferred/forward shaders and thus do not work with urp.
     
  21. svfritz

    svfritz

    Joined:
    May 13, 2021
    Posts:
    2
    Pfft, I completely overlooked it, like a dummy; I saw "URP 11" and "URP 7.2" and didn't fully read the rest of the filenames to put together that I needed both. Thank you for taking the time to reply!
     
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,212
    you are welcome!
     
  23. zedz

    zedz

    Joined:
    Aug 31, 2013
    Posts:
    94
    I had the same problem, this works for me
     
    Last edited: May 18, 2021
  24. contact_unity364

    contact_unity364

    Joined:
    Sep 28, 2020
    Posts:
    4
    I am getting an index out of range exception in GrassManager.cs GetfilteredHeight() and I notice a comment immediately before these are called on line 1931:
    // NOTE: When looking up the height map we need guards!!!!!!
    So, apparently these guards are indeed needed. I've put a try / catch within the method and return 0 when there is an exception. Any chance this could be fixed?
     
  25. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,212
    thanks for reporting!
    atg has been out in the wilde for quite some time and i haven't got any response like this for the last 24 months or so.
    so maybe you are using quite strange terrain settings? or use baked terrain data which is out of sync?
    if not it would be great if you could send me your terrain to check it out.
     
  26. lilacsky824

    lilacsky824

    Joined:
    May 19, 2018
    Posts:
    85
    Hi!
    How can I do to make density more sparse like built-in detail rendering? I want fade out density more smooth.
    Here is comparison.
    Left one is built-in with density set 0.1.
    Right one is ATG with density set 1.
    When I set density fewer it just render nothing. So I can't tweak density gradually as built-in.


    compare.jpg
     
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,212
    oh, you should be able to lower the density in atg as well.
    and of course you can use a low density when painting the grass!?
     
  28. lilacsky824

    lilacsky824

    Joined:
    May 19, 2018
    Posts:
    85
    When I lower density or use a low density when painting the grass. It won't render grass.

    By the way, I found grass rendered at where is terrain hole. How can I culling these grass?
     
    Last edited: May 25, 2021
  29. thepatchworkhoax

    thepatchworkhoax

    Joined:
    Apr 29, 2019
    Posts:
    21
    Sorry if this isn't the place to ask, but any advice on making grass be effected by colliders going through it, like the video with the spheres on your asset store page? I cannot figure it out and it doesn't seem to be happening in the 02 Full Demo
     
  30. arminiuskielpecache

    arminiuskielpecache

    Joined:
    Jun 15, 2020
    Posts:
    31
    Getting this error after the lastest version


    Shader error in 'Hidden/ATG-Internal-DepthNormalsTexture': undeclared identifier '_ScaleMode' at Shaders/Includes/GrassInstancedIndirect_Vertex.cginc(100) (on d3d11)

    Compiling Vertex program
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR
    Disabled keywords: _METALLICGLOSSMAP _NORMAL UNITY_NO_DXT5nm UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_NO_FULL_STANDARD_SHADER UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_COLORSPACE_GAMMA UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_RGBM_ENCODING UNITY_VIRTUAL_TEXTURING UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_ASTC_NORMALMAP_ENCODING SHADER_API_GLES30
     
unityunity