Search Unity

[Released] Advanced Terrain Grass

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

  1. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    I mean is there an asset that you know of that uses screen space rendering for grass, similar as there are assets that do screenspace shadows, I thought maybe there is something for grass with this technique, to allow further draw distances
     
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    very special question: leading you to another asset... :)
    but volumegrass by tom used to offer something like screen space grass.
     
    Lars-Steenhoff likes this.
  3. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    Yea sorry, I just was curious about this technique, Just bought your grass pack by the way!

    most of the grass shaders I found were using geometry shaders and this does not work on mac or ios with metal, so therefore was interested to find out there are other ways.
     
  4. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    pink2.jpg

    When using deferred on metal I get pink colors on the grass.
    Any idea what the reason can be?


    EDIT:

    I had to read the manual: Now it's all good

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

      Edit -> Project Settings -> Graphics:

      • ● Under the Built-in shader settings change Deferred to c ustom, then assign the ATG_Internal-DeferredShading shader.

      • ● Also change Deferred Reflections to C ustom and assign the ATG_Internal-DeferredReflections shader.
     
    Last edited: Nov 16, 2019
  5. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    Everything looks really nice

    grass.jpg
     
    Last edited: Nov 16, 2019
    transat, pixelR and TerraUnity like this.
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    Version 1.21 is available:
    # Single Pass Instanced rendering fixed (URP).
    # Grass shader (URP): Shadow caster threshold added.
     
    pixelR and Lars-Steenhoff like this.
  7. irfanaabbaxi

    irfanaabbaxi

    Joined:
    Oct 28, 2018
    Posts:
    8
    hi, is it possible to paint grass over a mesh?
     
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    atg only handles grass painted using a unity terrain.
    you may however assign the atg shaders to manually placed objects which then would be rendered using the regular rendering pipeline und GPU instancing: ok if you only have a "few" instances here and there you need full control over, but you can not add 100.000 manually placed instances: just imagine the amount of data and the size of your scene.

    if you have a mesh based terrain you can render a height map from it and assign this height map to a unity terrain. you can disable the rendering of the terrain itself so only the grass gets rendered.
     
  9. AnotherLazyPeon

    AnotherLazyPeon

    Joined:
    Sep 27, 2018
    Posts:
    5
    Hey, after importing asset into a clear project a get those.
    upload_2020-1-22_16-56-43.png

    I am working on 2019.2.17f1 Personal. Is this something to be worried about?
    #pragma shader_feature _SPECULARHIGHLIGHTS_OFF is uncommented in Grass_InstanceIndirect_Base.shader
     

    Attached Files:

  10. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    just ignore it.
     
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    after tweaking the custom random function the urp version runs smoothly on a google pixel (1).
    grass casts shadows and is tinted red to increase visibility...

    android.png
     
    Lars-Steenhoff likes this.
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    ATG for URP and touchbending or grass displacement - finally :)
    although it is just a first wip.

     
  13. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    I thought it was already working on URP?
     
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    yes, but not with the atg grass shader. only the LWRP/UP Essential grass shader have been supported so far.
     
  15. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    version 1.22 is available.

    # Grass Manager Script: Android bug in custom random function fixed.
    # URP Grass Shader: Touch bending added, culling option exposed, ambient reflection strength added.
    # URP Grass Shader: Support for main bending in alpha or blue added. This lets you use grass models authored for Lux LWRP Essentials, Vegetation Studio (Pro) and grass models from Naturemanufacturer.
    # Saved Terrain Data: [PreferBinarySerialization] added.
     
    Rowlan likes this.
  16. Game_DevKH

    Game_DevKH

    Joined:
    Jun 11, 2017
    Posts:
    23
    I use your shader here
     
    M_R_M, Lars-Steenhoff and transat like this.
  17. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    nice! although i do not see much of the shader but vs all over the place :)
     
  18. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    What’s the recommended approach for URP and the grass bending feature? Do I put my ATG prefabs on their own layer named “vegetation”, then create a “grass renderer data” forward tenderer asset and set the layer mask on that to the “vegetation” layer and add the grass displacement render feature to it?
    Or is there no advantage to that? In which case do I simply add all of my game’s features to the one forward renderer asset?
     
  19. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    Actually I’m seeing that grass manager can push the details to a layer so could skip setting prefabs individually I suppose?
     
  20. Game_DevKH

    Game_DevKH

    Joined:
    Jun 11, 2017
    Posts:
    23
    All those grass&foliage are ATG shader. Although I use Unity standard pipeline
     
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    no, you do not need an extra layer.
    the grass displacement render feature only renders objects using the provided shaders (used by the particle systems and displacement quads in the demo). enable debug to see the created render texture (which needs the debug script on the camera like in the demo).
    then this render texture get send to the grass shader which will displace the grass accordingly.
    so the grass displacement render feature renders the displacers only – not the grass.
     
    Rowlan and transat like this.
  22. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    Cool. Makes sense. Cheers Lars.
     
  23. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    I’ve just split my 8192x8192 terrain into 1024x1024 terrains. What would the recommended terrain settings be for terrain density, etc.

    I’ve got those terrains set up identically but for about half a dozen of the 64 terrains, the grass manager component’s GUI appears corrupted. Any ideas what could be causing that?
     
  24. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    unless you actually stream in the terrain data – i would keep the 8k terrain...
    no, sorry. how do the inspectors look like?
     
    transat likes this.
  25. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    Looks like this

    Screen Shot 2020-01-30 at 1.10.07 am.png

    But that won't be an issue anymore if i revert back to the 8k terrain. Was thinking of trying a streaming solution or putting them each in their own DOTS sub-scene but I suppose I should tackle that down the track if necessary. Working with so many terrains is a pain.
     
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hmm, you should get an error message from the inspector, do you?
     
  27. E_T_

    E_T_

    Joined:
    May 14, 2018
    Posts:
    19
    Will this work in HDRP?
     
  28. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    Just an update on my UI glitch. Not sure what I did but it’s fixed and hasn’t reoccurred.
     
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    it does not right now. but i will probably port it. no eta tho.
     
    Weendie-Games and E_T_ like this.
  30. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    Is this URP 7.2.x friendly? I’m on 2020.1.0a23 and recent changes have messed up the shadowing (black borders on cascades). ATG seems fine but just checkin’. Something about shadows having to be per-pixel now and not per vertex?
     
  31. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    not yet.
    because shadows have totally changed.
     
  32. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    Ok cool. Hopefully it will be a change for the best. Any ETA on how long it might take you? Happy to beta test if needed.
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i just submitted the updated package.
     
    transat likes this.
  34. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    Version 1.23 for URP 7.2. is available.
     
    transat likes this.
  35. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    298
    What would cause the Vegetation Studio shaders to render invisible? I followed all setup instructions and can't get it to work. Regular shaders work fine. All shaders are set in the Graphics settings and instanced indirect is set. Standard pipeline. Just testing out demo assets so no changes have been made on my side.

    Unity_2020-03-08_20-27-32.png
    Left is ATG VS shader, right is regular ATG grass.


    Take note, the background terrain is filled with the ATG VS grass, but you can't see it. If I change the shader of course it appears.
    Unity_2020-03-08_20-31-05.png

    Any ideas?
     
  36. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    try and check "Ignore Fading (VS Pro)".
     
    Freznosis likes this.
  37. E_T_

    E_T_

    Joined:
    May 14, 2018
    Posts:
    19
    Man I'd love to have this working in HDRP
     
    Weendie-Games likes this.
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    stay calm...
     
    Ali-Nagori likes this.
  39. krullulon

    krullulon

    Joined:
    Oct 23, 2015
    Posts:
    2
    Has anyone experienced "wandering" grass? Wind works as expected when playing in the editor and bends, but it actually translates back-and-forth a short distance along x-z in the build.
     
  40. Regulus343

    Regulus343

    Joined:
    Jul 4, 2013
    Posts:
    11
    I'm using this in a VR game, and I've had to tweak some of the shaders over the months, but even when I was able to get it to build, it would still show errors like these once and the build would fail. I would then start the build over and the second time it worked (if Unity didn't get shut down after the first attempt). But now, after installing Unity on a new PC, I get this every time. Is there something I'm doing wrong? Thanks.

     
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hmm, i know this problem: build fails at the first attempt, second one works.
    as you tweaked the shaders all i can say: go ever the errors one by one.
    regarding the deferredshading shader: get the built deferredshading shader that ships with the version of unity you use and look how it is done there. should be in the second pass.
     
  42. zedz

    zedz

    Joined:
    Aug 31, 2013
    Posts:
    253
  43. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    zedz likes this.
  44. zedz

    zedz

    Joined:
    Aug 31, 2013
    Posts:
    253
    Thanks mate, I'll post the exact error messages as that will prolly help.

    (later)
    Well what do you know, I downloaded the new version of Advanced Terrain Grass from feb 25, and now it builds good. I was running a previous version

    here were the error messages FWIW

    Code (csharp):
    1.  
    2. Compressed shader 'ProBuilder/Standard Vertex Color' on d3d11 from 1.36MB to 0.10MB
    3. Compiled shader 'AdvancedTerrainGrass/Grass Array Shader' in 1.46s
    4.     d3d11 (total internal programs: 190, unique: 190)
    5. Shader error in 'AdvancedTerrainGrass/Grass Array Shader': invalid subscript 'texcoord1' at line 276 (on d3d11)
    6.  
    7. Compiling Vertex program with UNITY_PASS_FORWARDBASE DIRECTIONAL SHADOWS_SHADOWMASK LIGHTPROBE_SH _MIXMODE_RANDOM
    8. 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
    9. Compiled shader 'AdvancedTerrainGrass/VertexLit Shader' in 2.58s
    10.     d3d11 (total internal programs: 318, unique: 318)
    11. Shader error in 'AdvancedTerrainGrass/VertexLit Shader': invalid subscript 'texcoord1' at line 159 (on d3d11)
    12.  
    13. Compiling Vertex program with UNITY_PASS_FORWARDADD POINT SHADOWS_SHADOWMASK
    14. 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
    15. Shader error in 'AdvancedTerrainGrass/VertexLit Shader': invalid subscript 'texcoord1' at line 246 (on d3d11)
    16.  
    17. Compiling Vertex program with UNITY_PASS_FORWARDBASE DIRECTIONAL SHADOWS_SCREEN LIGHTMAP_SHADOW_MIXING SHADOWS_SHADOWMASK LIGHTPROBE_SH
    18. 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
    19. Compressed shader 'AdvancedTerrainGrass/VertexLit Shader' on d3d11 from 1.15MB to 0.10MB
    20.  
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i just tested latest atg in 2019.3.7. and did not come across any error either :)
     
  46. luigiboccardo3

    luigiboccardo3

    Joined:
    Apr 11, 2020
    Posts:
    2
    Someone can help me? i do this passage ATG :
    ATG offers advanced lighting features such as translucency and physically inspired specular reflections on grass. 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. In case your camera uses forward rendering and you have any depth based image effects applied (like ssao) you have to assign the ATG_Camera-DepthNormalTexture shader in Edit -> Project Settings -> Graphics: ● Switch to Debug (using the dropdown icon in the upper right corner of the inspector) in order to bring up the all inputs. ● Change Depth Normals to Custom Shader, then assign the ATG_Internal-DepthNormalsTexture shader.
    BUT when i go in play mode grass disappear ( sorry for english im italian ) someone can help me? and how can use it with gaia pro? with same passage?
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    grass disappearing has nothing to do with deferred or forward and overwriting the built in shaders.
    so first you have to make sure that grass renders regardless of the deferred shaders. make sure that your camera is tagged as maincamera and that you do not get any errors.
     
  48. irfanaabbaxi

    irfanaabbaxi

    Joined:
    Oct 28, 2018
    Posts:
    8
    i'm using the ATG grass and foliage shaders for vegetation studio pro but having alot of problems. The grass goes invisible at times in the editor (sometimes it appears). And in the build it never shows up at all.

    I have assigned the two deferred shaders to graphics settings as in the documentation.

    FYI, 'ignore fading' (VS Pro) is checked.
     

    Attached Files:

  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    have you added the atg wind prefab to your scene? if it is missing grass may go crazy.
     
  50. GCatz

    GCatz

    Joined:
    Jul 31, 2012
    Posts:
    282
    any chance to make it work in WebGL 2.0 ?