Search Unity

  1. 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. kotlaska

    kotlaska

    Joined:
    Oct 29, 2020
    Posts:
    3
    Hello, I work with additive scenes with terrains. Is it possible to display ATG? I have one Camera tagged as MainCamera in Base scene. I tried to edit GrassManager so it knows where MainCamera is, all Terrains has their own Grass Manager but it still renders the Unity's default grass. It's my second project with ATG
    Edit: now the Unity's grass is dissappearing when i hit play
    Edit2: Ok it works after lots of changes in code
     
    Last edited: Jan 24, 2022
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,874
    looks like it it related to your terrain (size and resolution).
    so the rendering should stop always at the same location? somewhere when you reach the border of your terrain?
    is your terrain of square size? limitation of ats...
    if so - i haven't run into such kind of error for quite some years now - but of course my calculations might fail under certain conditions. so you could add some safeguards here:

    around line 1900 you will find:
    float HeightLowerLeft = TerrainHeights [ normalizedHeightPosLower_x + normalizedHeightPosLower_y ];
    float HeightUpperRight = TerrainHeights [ normalizedHeightPosUpper_x + normalizedHeightPosUpper_y ];
    so in order to make sure you never sample outside the given TerrainHeights array you may replace it with:
    var hlf = normalizedHeightPosLower_x + normalizedHeightPosLower_y;
    var hul = normalizedHeightPosUpper_x + normalizedHeightPosUpper_y;
    hlf = Math.Max(0, hlf);
    hul = Math.Min(TerrainHeightmapWidth * TerrainHeightmapWidth - 1, hul);
    float HeightLowerLeft = TerrainHeights [ hlf ];
    float HeightUpperRight = TerrainHeights [ hul ];


    btw: using just textures = quad per grass instance really wastes GPU power as it only processes 4 vertices although it could handle 32 or 64 in parallel.
    --> use more complex grass meshes with 32, 64, 96, ... vertices at least

    a cell size of 93x93 won't let you cull cells efficiently on the cpu (fast).
    --> consider lowering "buckets per cell"
    setting "grass density" to 3 will give you a quantized or blocky distribution:
    0 * 3 = 0, 1 * 3 = 3, 2 * 3 = 6, ... you get the steps that this will produce?
    so you should use "grass density" always only to LOWER the density for best visual result.
    --> using more complex grass meshes and not just quads which have an extent like 0.25*.25 meters up to 0.4*0.4 meters should a) allow you to set density back to 1 and b) speed up rendering
     
  3. russmac316

    russmac316

    Joined:
    Apr 27, 2021
    Posts:
    5
    I just bought ATG, Demo scene works great (in HDRP), but when I add the Grass Manager script to my terrain, the prototypes section is completely blank. Anybody know what's going on here?
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,874
    how do your prototypes look on the terrain?
     
  5. jcochran

    jcochran

    Joined:
    Oct 9, 2015
    Posts:
    8
    I cant get this asset to work with unity 2021 and newest URP. A video tutorial would be helpful.
     
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,874
    where do you get stuck?
     
  7. newcarrotgames

    newcarrotgames

    Joined:
    Feb 1, 2022
    Posts:
    2
    After importing the asset, the materials are still pink even after running the upgrade material to URP command. Here's a screenshot of my progress:

    upload_2022-2-23_8-40-41.png

    I'm guessing this is just an issue with my project. I'm using Unity version 2020.3.26f1.1470. I've converted my project to URP only recently however.

    Using the demo scene, I can see the grass in the editor, but not once I click the play button:

    upload_2022-2-23_8-45-33.png

    but this is what I see when I try to play the scene:

    upload_2022-2-23_8-46-30.png

    I'm going to try creating a new project from scratch to see if upgrading an older project to URP is causing this to happen. Any advice will be greatly appreciated!
     
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,874
    the "upgrade material to URP command" does not do anything in case of atg. it simply takes care of materils using the BIRP standard shader.
    the first step after importing the package is to install the provided atg URP package as well - which comes with a new demo scene which contains URP in its name.
     
  9. newcarrotgames

    newcarrotgames

    Joined:
    Feb 1, 2022
    Posts:
    2
    I realized that after creating a new project. Here's what I'm seeing now:

    upload_2022-2-23_9-52-25.png

    upload_2022-2-23_9-52-50.png

    upload_2022-2-23_9-51-33.png

    I've installed the 7.2 package and the 12.1 URP package. The screen shots should show that I have opened the "Full Demo URP" scene. Any ideas?
     
  10. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,874
    in which order did you install the packages? 1st urp 7.2, then urp 12.1?
    the shader should not error.
     
  11. Mydel

    Mydel

    Joined:
    Apr 15, 2021
    Posts:
    12
    Hey i have a problem with grass texture, it looks like lightning done affect it in any way? Any suggestion how i can fix it?
    upload_2022-3-16_16-46-44.png
     
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,874
    which render pipeline do you use? forward or deferred? atg implements custom translucent lighting. but it does not add light where there is none.
     
  13. Mydel

    Mydel

    Joined:
    Apr 15, 2021
    Posts:
    12
    Right Now im using Forward rendering, how can i fix this situation where i dont have any light but texture is too bright?
     
  14. Mydel

    Mydel

    Joined:
    Apr 15, 2021
    Posts:
    12
    Also In project we are suing lightmaps from Bakery asset, is it possible somehow to make it work?
     
  15. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,874
    if the texture is too bright you should darken it in photoshop?! but if you are using lightmaps on the rest of the assets it might just be the ambient which is too bright. so you could try to raise the occlusion.
     
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,874
    lightmaps are not supported officially. it is rather tricky, would need different materials for different terrains and one lightmap per terrain.
     
  17. Haxel0rd

    Haxel0rd

    Joined:
    May 20, 2021
    Posts:
    49
    Incase anybody who bought this and using HDRP has empty terrain / no grass / blank terrain in playmode),
    then you have probably opened the wrong Demo. The HDRP Demo is not in the Demo folder, it is in a
    separate folder called "HDRP". For me, it's working with unity 2021.2.12f on HDRP. It uppers fps for me a lot (about 20-40), amazing Tool, kudos to the author!
     
    Last edited: Mar 27, 2022
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,874
    it "reduces" fps?
     
  19. Haxel0rd

    Haxel0rd

    Joined:
    May 20, 2021
    Posts:
    49
    Sorry i meant the opposite, it uppered the fps. I edited the post accordingly.

    At the moment i am having a problem;
    in the Demo scene, the grass renders miles far away and reliably renderes in editor too.With the same setup in a different scene, the rendered distance is very low and in editor it renders only small chunks. If anyone knows a solution, i would be really thankfull.

    EDIT: got it working - great plugin, the grass renders really far!! A full 5 Star asset here!
     
    Last edited: Apr 27, 2022
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,874
    pm sent. look for terrain size, bucket size and all that stuff.
     
  21. kotlaska

    kotlaska

    Joined:
    Oct 29, 2020
    Posts:
    3
    Hi! Could you please tell me how should I setup ATG when my main camera is on other scene than my terrains?
     
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,874
    it should be enough to make just sure that your camera is tagged as "maincamera"?!
     
  23. kotlaska

    kotlaska

    Joined:
    Oct 29, 2020
    Posts:
    3
    Idk what I did wrong, but I updated ATG and it works now. Thanks for your response!
     
  24. Patrudoizero

    Patrudoizero

    Joined:
    Nov 30, 2018
    Posts:
    13
    On Unity 2021.1, when building the project I get two errors:
    "Shader error in 'AdvancedTerrainGrass URP/VertexLit': Output variable ShadowPassVertex contains a system-interpreted value (SV_RenderTargetArrayIndex) which must be written in every execution path of the shader. Unconditional initialization may help. at line 280 (on d3d11)"
    and
    "Shader error in 'AdvancedTerrainGrass URP/Foliage': Output variable ShadowPassVertex contains a system-interpreted value (SV_RenderTargetArrayIndex) which must be written in every execution path of the shader. Unconditional initialization may help. at line 344 (on d3d11)"
    Any idea on what to look for?
    Thanks!
     
  25. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,874
    these errors do not make much sense to me. the shadow pass should never need a "RenderTargetArrayIndex". this target array index sounds a bit like vr - where the both eyes may be rendered into different slices of an array. this however shall never happen to shadows as they get rendered into an atlas, not an array.

    nevertheless testing latest (again!) in 2021.2 and urp 12.1.0 i do not get any errors at all doing a build.
     
  26. Patrudoizero

    Patrudoizero

    Joined:
    Nov 30, 2018
    Posts:
    13
    Yes, it is for VR.
    If I disable the VR camera rig the app builds without error.

    Later: The problem has solved itself. I don`t know what i changed, but now I can build without errors.
     
    Last edited: Apr 15, 2022
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,874
    very strange...
     
  28. wechat_os_Qy0xcELMZfcGdmpy5snESkx-w

    wechat_os_Qy0xcELMZfcGdmpy5snESkx-w

    Joined:
    Apr 23, 2022
    Posts:
    9
    Hello author, in the URP of the unity20203.3 version, the shader of Rock does not support URP10.8, the shader of Terrain Grass cannot be applied, and the shader is always purple, how can I solve this problem, thank you
     
  29. wechat_os_Qy0xcELMZfcGdmpy5snESkx-w

    wechat_os_Qy0xcELMZfcGdmpy5snESkx-w

    Joined:
    Apr 23, 2022
    Posts:
    9
  30. wechat_os_Qy0xcELMZfcGdmpy5snESkx-w

    wechat_os_Qy0xcELMZfcGdmpy5snESkx-w

    Joined:
    Apr 23, 2022
    Posts:
    9
  31. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,874
    you are usig shaders for the built in render pipeline - not urp.
    you have to import the urp package and then go to the urp demo.
     
  32. wechat_os_Qy0xcELMZfcGdmpy5snESkx-w

    wechat_os_Qy0xcELMZfcGdmpy5snESkx-w

    Joined:
    Apr 23, 2022
    Posts:
    9
    Thank you very much for your reply, I imported URP support7.2 and the shader package of URP and replaced it. The project setting of unity is definitely URP. When I open it again, it is still the same, and I don't know where it is. question
     
  33. wechat_os_Qy0xcELMZfcGdmpy5snESkx-w

    wechat_os_Qy0xcELMZfcGdmpy5snESkx-w

    Joined:
    Apr 23, 2022
    Posts:
    9
  34. wechat_os_Qy0xcELMZfcGdmpy5snESkx-w

    wechat_os_Qy0xcELMZfcGdmpy5snESkx-w

    Joined:
    Apr 23, 2022
    Posts:
    9
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,874
    find the urp demo. it has everything set up properly.
     
  36. wechat_os_Qy0xcELMZfcGdmpy5snESkx-w

    wechat_os_Qy0xcELMZfcGdmpy5snESkx-w

    Joined:
    Apr 23, 2022
    Posts:
    9
    Thank you for your reply, but I'm sorry, I opened the URP Demo and it was displayed like this, I'm at a loss, I don't know what happened when you opened it with 2020, I read the official documentation, and there are still many questions, I don't know I would be honored if you could give me some teaching links, thanks a lot
     
    Last edited: Apr 25, 2022
  37. wechat_os_Qy0xcELMZfcGdmpy5snESkx-w

    wechat_os_Qy0xcELMZfcGdmpy5snESkx-w

    Joined:
    Apr 23, 2022
    Posts:
    9
    I'm sorry to bother you, I have one more question, this sentence ATG is not an authoring tool: It simply takes the grass and details you have added to your terrains and takes over their rendering. That means I can add any In some detail Mesh under the shader resource of your URP environment, the material must be converted to a certain material in Advance terrain Grass URP, thus saving my CPU usage, thank you
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,874
    well, definitely not "any" mesh. if you add grass as detail meshes (which i recommend) and not only simple textures you need a detail mesh with proper vertex colors to drive the bending.
     
  39. wechat_os_Qy0xcELMZfcGdmpy5snESkx-w

    wechat_os_Qy0xcELMZfcGdmpy5snESkx-w

    Joined:
    Apr 23, 2022
    Posts:
    9
    OK, this is really a powerful tool. I see. Thank you. I tried several times, imported the URP and URP package resources, opened the URP demo, and found that the prafab in the terrain details has always been purple. Although I changed the shader you provided, it still doesn't display. I don't know why. It bothered me for several days
     
    Last edited: Apr 26, 2022
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,874
    if you really opened the proper urp scene and get pink grass you may be using the wrong version of urp.
    go to the urp shaders and check if they error.
     
  41. backwheelbates

    backwheelbates

    Joined:
    Jan 14, 2014
    Posts:
    231
    Hi, Id also like to report that Im having trouble seeing any of the demos in Unity 2021 and in 2022 with the latest URP.
     
  42. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,874
    which version of urp do you use?
     
  43. backwheelbates

    backwheelbates

    Joined:
    Jan 14, 2014
    Posts:
    231
    Im testing with URP 12.1.6 in Unity 2021.3.0f1

    Also, strangely the Camera inspector has some visual bugs in the Grass Displacement Render Feature ATG Demo scene

    upload_2022-5-3_11-56-16.png

    upload_2022-5-3_11-58-58.png
     
  44. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,874
    urp 12.1 should be absolutely fine.
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,874
    just to make sure i created a new project in 2021.3.1. then i imported the package, imported the atg_urp_7.2_support and atg_urp_grassdisplacment and finally updated all by importing the atg_urp_12.1_shaders package:
    everything just works. and no visual bugs regarding the camera inspector.

    inspector.PNG
     
  46. backwheelbates

    backwheelbates

    Joined:
    Jan 14, 2014
    Posts:
    231
    Ah, I might have missed one of the imports then. Its quite confusing!
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,874
    it is pretty straight forward if you read the urp 12.1. readme :)
     
    Last edited: May 7, 2022
  48. wifitofu

    wifitofu

    Joined:
    May 18, 2021
    Posts:
    6
    There seems to be a massive bug with adding additional detail layers. For some reason, adding a layer breaks the shadow casting of the grass on the already existing layers. Also, in URP 12 the ATG URP Grass shader has an error "UniversalFragmentBlinnPhong" : no matching 6 parameter function.

    *Edit: The blinn phong bug can be fixed by changing line 181 in "ATG URP Grass ForwardLit Pass.hlsl" from:

    half4 color = UniversalFragmentBlinnPhong(inputData, surfaceData.albedo, half4(surfaceData.specular, surfaceData.smoothness), surfaceData.smoothness, surfaceData.emission, surfaceData.alpha);

    to: half4 color = UniversalFragmentBlinnPhong(inputData, surfaceData);

    Because the UniversalFragmentBlinnPhong function was changed in v12 apparently
     
    Last edited: May 23, 2022
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,874
    thanks for reporting. this will be fixed with the next update.
    i could not reproduce this. do you have any further information?
     
  50. backwheelbates

    backwheelbates

    Joined:
    Jan 14, 2014
    Posts:
    231
    Thanks @larsbertram1, I was able to get things working in the stylized grass scene by clicking "Update Grass".

    Although I have a small issue. When I have Draw In Edit mode unchecked, the grass looks like this (red/green)
    upload_2022-6-14_10-27-36.png

    When I do have it checked, the grass is invisible in the editor window. I can see the shadow though.
    upload_2022-6-14_10-28-39.png

    The render cam looks good
    upload_2022-6-14_10-29-25.png

    Do you have any ideas on how to fix the grass display in the editor window?