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


    ATG is a grass rendering solution which was built to replace the detail rendering system of Unity’s terrain engine in order to get rid of almost all spikes on the CPU — which usually are caused by new grass patches coming into sight when your camera is moving. So ATG will help you to reduce work on the CPU – but at the same time it might add some more costs on the GPU side.

    Next to this initial purpose ATG offers significant improvements regarding lighting and wind animation.

    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 being said ATG is compatible with any 3rd party authoring solution that allows you to create grass density maps for built in terrains within the Unity editor like e.g. Terrain Composer, Map Magic, World Creator or Gaia. Runtime distributed grass currently is not supported.

    Get it on the asset store


    Benefits
    ATG was built to avoid major spikes on the CPU and gives you quite stable and reliable costs per frame, or — in order to be more specific — time slices and shifts work from the main thread to a worker thread and the GPU.

    It lets you use advanced lighting features such as physically inspired specular highlights and translucent lighting and enables any grass prototype to even cast real time shadows.

    Limitations
    ATG is mostly suitable in case you are CPU bound.

    ATG needs DX11, Metal (tested on OS X – not iOS) or OpenGLCore (Linux or Windows, Mac is not supported). Xbox One and PS4 should be fine as well although i have not been able to test it.

    ATG currently only works on squared terrains and does not support Detail Resolutions < 256. Billboarded grass is not supported either.

    ATG currently does not support lightmaps. And it does not support real time lightmaps as well, which — unfortunately — is by design, as Unity does not let us access real time lightmap data from script.

    Fast moving cameras currently may cause grass to just pop in. A speed of 6 (fpc) – 10 just should be fine.

    00_cpu-performance.jpg

    02_wind.jpg

    03_shaders.jpg

    04_aligment.jpg
     
    Last edited: Aug 7, 2019
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    Preview of ATG's lighting and wind features:

     
    Last edited: Sep 21, 2017
    JBR-games, Arkade, Vondox and 2 others like this.
  3. claudius_I

    claudius_I

    Joined:
    May 28, 2017
    Posts:
    251
    look awesome

    date release and price?
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    i have submitted it more than a week ago. so it should hit the asset store within the next 2 weeks i hope.
    price is 27eur + vat.
     
  5. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,369
    SiDuGames likes this.
  6. coverpage

    coverpage

    Joined:
    Mar 3, 2016
    Posts:
    385
    This is exciting. How is it different from using uNature as a grass solution.
     
  7. camel82106

    camel82106

    Joined:
    Jul 2, 2013
    Posts:
    304
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    thanks.
    sorry, not now. but i just works of course (tested with Next-Gen Soft-Shadows).
    well, that is very special – and would need to initialize multiple cells within a given frame. or use rather large cell sizes. so it is probably nothing atg will support right out of the box – but should be rather simple to implement.
    in case you are going to work on this just come back to me to find out the most elegant way.

     
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    oh, it uses a totally different approach and derives grass distribution directly from the built in terrain, always, ever.
    not to mention its shaders.
     
    coverpage likes this.
  10. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    that pigment map would have to be created by your terrain shader like rtp, mega / micro splat, cmu or cts as the grass manager does not know how the terrain actually gets rendered. once you have that map it is just a few lines in the shader code.
     
  11. camel82106

    camel82106

    Joined:
    Jul 2, 2013
    Posts:
    304
    I understand, for example megasplats have this feature. You can render terrain into texture. It's than used for macro texture feature.

    Although those few lines of shader code would be still appreciated ;)
    Looking forward to new grass solution!
     
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    cmu has it too. so it might come with one of the next updates.
     
  13. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,694
    finally... good looking unity grass! nice work
     
  14. Migueljb

    Migueljb

    Joined:
    Feb 27, 2008
    Posts:
    562
    Does this also let you plant unity detail grass using the direction the terrain normals are facing? So no more just straight up floating grass on angles of the terrain going up or on cliff areas.
     
  15. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    yes. it actually is the preferred way to render at least smaller grass entities.
     
  16. Migueljb

    Migueljb

    Joined:
    Feb 27, 2008
    Posts:
    562
    Hey lars big fan of AFS v4 and 5. You were able to get lightmapping in those packages anyway we can get lightmapping with this new grass package as well? Latest version of unity 2017 has a great lightmapping feature called shadow mask its pretty much like in unity 4 how dual lightmaps used to work. Be great to have this new grass/detail system working with unitys new shadow mask lightmapping.
     
  17. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    baked light maps may come in the future.
    precomputed real time gi however is impossible – at least with unity 5.6 or 2017 – as there is no api to access the real time light maps.
     
    Last edited: Sep 25, 2017
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    Just a really rough version using NGSS:

     
    magique, coverpage and Elecman like this.
  19. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,369
    Thanks, that looks really nice!
     
  20. docsavage

    docsavage

    Joined:
    Jun 20, 2014
    Posts:
    1,020
    Hi @larsbertram1,

    This looks great.

    Just wondering if this is a replacement for AFS or something that can work in conjunction with it?

    Thanks

    doc
     
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    thanks.
    and i hope i can make both systems work hand in hand in the near future.
     
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    coverpage and gecko like this.
  23. coverpage

    coverpage

    Joined:
    Mar 3, 2016
    Posts:
    385
  24. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    both share the (deferred) translucent lighting and some of the basic concepts as far as the wind animation in the vertex shader is concerned. but while afs' grass shader simply overwrites the original shader and uses the built in functions to draw all grass on the terrain, the advanced terrain grass goes a step further and replaces unity's grass rendering on the terrain in order to get rid of almost any spike on the cpu.
    afs addresses grass, foliage and trees. atg focuses on grass and smaller foliage. it is limited to unity's terrains giving you better performance and much more lively shading.
     
    coverpage likes this.
  25. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,369
    Any chance getting this to work on a regular mesh instead of Unity terrain? Unity terrain itself is a thing to avoid if you care about performance.
     
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    atg uses the same abstraction as unity's terrain.
    so to make it work with a custom mesh you first would have to create height map like data e.g. using ray casts.
    next thing are the density maps: atg does not come with a custom grass brush but relies on the terrain tools. so you would have to feed in density maps somehow else.

    right now the easiest solution would be to create a height map from your mesh and assign it to a unity terrain.
    then populate the terrain with grass so atg can grab all needed information from the terrain.
    when it comes to rendering simply do not draw the terrain but use your mesh instead.

    atg lets you safe all data (heights and density) to a scriptable object. so when you are ready you may even remove the terrain completely (although you will have to make minor tweaks to the script).
     
  27. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,369
    Ok, thanks for the workaround. That will do for now. A native solution would be nice though :)
     
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    let's see what the future will bring. once there is a native or at least widely used solution for mesh based terrains i might add native support for that :)
     
  29. claudius_I

    claudius_I

    Joined:
    May 28, 2017
    Posts:
    251
    what do you thinks is
    so i can use the two in a project?
     
  30. Dark-Muppeteer

    Dark-Muppeteer

    Joined:
    Feb 24, 2013
    Posts:
    26
    I'm having some issues with sideways grass along seams between multiple terrains, any good solution for this given that I'd like the be able to keep the grass conforming to the terrain normals everywhere else (since it looks so much better)?

    SidewaysGrass.jpg

    I'm also getting some strips of land that are not getting grass applied, like a long bald strip of land that crosses multiple terrains, any ideas?
     
  31. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    right now wind will look different. and afs does not support atg grass lighting in deferred. so you would have to use the atg deffered lighting shader.
    but it should work.
     
  32. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    oh, i have never seen something like this before.
    so it would be very helpful if you could send me your terrains (without textures) and a scrren shoot from your settings in the grass manager.
    alternatively you could also write your terrain settings (size, height map resolution, detail resolution) here so i can reproduce your problem.

    i guess i will have to use more aggressive safe guards when sampling the terrain normal.

    that is even more strange. do you have a screen shoot which shows where on the terrain this happens and how it looks like (pattern)?
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    i just did another quick test and split a 1026x1026 height map into four 513x513 chunks.
    then i imported these 4 height maps on four terrains each 200x200x100 meters in size, laid out some grass and attached the grass manager to each terrain.

    using a cell size of 12.5x12.5 meters i do not get any artifacts as far as the rotation of the grass is concerned!?
    see screen shoots below.
    so having your data would really be helpful to get your problem solved :)


    fig 1 screen shoot showing the junction of the 4 terrains. the terrains here are not stitched so you can see a seam in the foreground. grass however seems to be fine.

    unstitched_jpg.jpg

    fig 2 same four terrains. now stitched using stitchscape.

    stitched_jpg.jpg
     
  34. Dark-Muppeteer

    Dark-Muppeteer

    Joined:
    Feb 24, 2013
    Posts:
    26
    Hi,

    Screenshots below as requested, I'll package up the terrains and send them to you via DM (they're a store asset so didn't want to put them on here directly).

    Grassless.png
    The grassless section, you can see by the dark grass bottom left that it crosses multiple terrains.

    GrassSettings.png
    The same settings are used on each terrain (9 terrains total in a 3x3 arrangement)
     
  35. secondsight_

    secondsight_

    Joined:
    Mar 2, 2014
    Posts:
    163
    Hey,
    Briefly read the documentation, still two questions:

    1. It is fully compatible with MapMagic grass generation ?
    2. The maximum render range can be raised (unity default is 200) ?

    Thanks!
     
  36. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    i don't know what "fully" means. mapmagic writes to the terrain (prototypes, densities), atg reads from it.
    you could raise the render range. but i would never do so as it will most likely kill your fps.
     
  37. secondsight_

    secondsight_

    Joined:
    Mar 2, 2014
    Posts:
    163
    Hmmm... I thought that´s what these packages are for ? :) But okay, then I´ll skip this. This is the function I´m actually looking for.
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    sorry, but what do you mean?
    atg can simply take over rendering of grass generated by map magic – but unfortunately not from terrains which are generated at runtime.
    and as far as the grass distance is concerned: there simply is no way to render grass at a distance of e.g. 500 meters as grass produces a lot of overdraw thus exhausting the fill rate.
     
  39. secondsight_

    secondsight_

    Joined:
    Mar 2, 2014
    Posts:
    163
    Thanks for the reply, that was the answer I was looking for because my terrain is generated on runtime.
    As for the grass distance: There are other packages (like uNature) that can increase the draw distance of grass. I wasn´t sure if this package here is also capable of that.
     
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    unature will suffer from exact the same problem: overdraw.
    this will always limit you in case you use mesh based grass. you may however combine it with e.g. screen space grass which might kick in at far viewing distances.
     
  41. Migueljb

    Migueljb

    Joined:
    Feb 27, 2008
    Posts:
    562
    Whats the difference between using latest AFS v5 for grass mesh's or using this system for grass mesh's?
     
  42. coverpage

    coverpage

    Joined:
    Mar 3, 2016
    Posts:
    385
  43. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    afs' grass shader simply overwrites the original shader and uses the built in functions to draw all grass on the terrain. the advanced terrain grass goes a step further and replaces unity's grass rendering on the terrain in order to get rid of almost any spike on the cpu.
     
  44. Migueljb

    Migueljb

    Joined:
    Feb 27, 2008
    Posts:
    562
    Thanks for clearing that up.

    So using unitys default on terrain Add Detail Mesh for grass meshes the lighting will bake in shadows and look correct. Will this system do the same being it's overiding that system?
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    i do not really understand this sentence, sorry.
    no one bakes shadows and lighting always is only an approximation.
    the afs grass shader simply takes the meshes like they are generated by the terrain engine – latter causes these heavy spikes on the cpu as generating meshes has to be done on the main thread and simply takes some time.
    atg however does not rely on meshes from the terrain engine. it draws patches of grass using drawmeshinstancedindirect. all you need for this is the base mesh and bunch of matrices – which get calculated on a worker thread. so no spikes on the cpu.
    and as atg draws the grass itself you may activate cast shadows – unlike on grass rendered by the terrain engine.
    you may compare the afs and atg grass shader as far as translucent lighting is concerned. anything else like specular lighting, wind and the way grass gets drawn is unique to atg.
     
  46. Migueljb

    Migueljb

    Joined:
    Feb 27, 2008
    Posts:
    562
    Ok that makes alot of sense and good to know very cool asset you created. Thanks.
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    hi there,

    the first update has been published today which fixes the bug reported by @Dark-Muppeteer and gives you stable and reliable shadows – in case you use unity 5.6.3 or above.
    minor performance improvements are included as well.
    enjoy.
     
    Dark-Muppeteer and JBR-games like this.
  48. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    647
    Hello I have a one more question Should I place grass on terrain using bilboard or mesh mode? How advance grass know knows what is what I mean if I place my grass on unity terrain tere is only for example bilboard texture so how it knows and change it on proper prefab/mesh ?
     
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    mesh mode as billboards look awful. atg will add meshes anyway.
    and you can always change the mesh used to render the grass: if you add a simple texture atg will use a simple quad – which you may replace by a custom mesh at any time.
     
  50. jimburn

    jimburn

    Joined:
    Apr 1, 2017
    Posts:
    64
    Is it faster than using Unity's grass?