Search Unity

[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,900
    it looks as if the quads used by the 2d grass do not have proper vertex colors as their lower vertices get displaced as well. vertex color alpha should be 0.0 at lower vertices which prevents them from being bent.
    which quad have you assigned to the 2d grass?
    i just tested a build of the "full demo scene" where the "dry grass" uses the default "Atg BaseQuad" mesh: It looks fine on dx11 and unity 5.6.3f1
     
  2. Olafson

    Olafson

    Joined:
    Aug 7, 2012
    Posts:
    255
    Thanks for coming back so quickly. Yeah it looks like that, but I am infact using the Atg BaseQuad mesh, as there is no real reason to make my own.

    It works fine when I press play in Editor, only in build it screws up.
     
  3. Olafson

    Olafson

    Joined:
    Aug 7, 2012
    Posts:
    255
    I fixed it. Apparently having "Optimize Mesh data" ticked on in Player Settings causes it to drop vertex coloring for this mesh.

    Thank you for the help!
     
    BlandonDu likes this.
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    what da f*ck!
    you should file a bug report.
     
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    btw: your scene looks pretty nice. i especially like the trees. any chance to see more?
     
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    version 1.09 has been submitted and should hit the asset store within the next 2 or 3 days.
     
    BlandonDu likes this.
  7. BlandonDu

    BlandonDu

    Joined:
    Dec 26, 2016
    Posts:
    10
    Hey Lars,I have added some my own code in the sourse, so could you give a brief feature description of your update? does the "floating origin" mean the grass system will move along with the terrain now?
     
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    yes.
     
  9. Olafson

    Olafson

    Joined:
    Aug 7, 2012
    Posts:
    255
    Yeah, it is a stupid bug.

    We are supposed to release a new Blog Post "soonish", but anyone that knows us also knows that the word "soon" means far away in the future :p

    Well I will post something here regardless, if there is ever anything worth showing. Not sure if you are intersted in screenshots or in videos, screenshots should be fairly easy to produce. Anyway, thanks so far.
     
  10. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i am interested in pretty much anything.
    when i started to work on atg there was only one single use case. now that there are hundreds of different use cases it is quite important to get a picture of what you developers actually are trying to archive.
     
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    version 1.09 is live now.
     
  12. Frozmat-Games

    Frozmat-Games

    Joined:
    Dec 17, 2012
    Posts:
    25
    Hello. All grass in demos is white. How can I fix this? Atg deffered lighting and reflection shaders is assigned. Unity 2017.4
     

    Attached Files:

  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    for me it looks absolutely fine in 2017.4 (win 10 pro, dx11, gtx 970m).
    have you checked the gbuffers already? does the albedo contains proper grass colors?
    maybe textures are missing.


    atg_2017.4.PNG
     
  14. Frozmat-Games

    Frozmat-Games

    Joined:
    Dec 17, 2012
    Posts:
    25
    I figured out what the problem is. I used "deffered lighting and reflection" shaders from AFS 5. After I replaced them with ATG shaders, everything work fine. Looks exactly how I need it :)

    Thank you for the second wonderful asset that I bought from you!

    (sorry for my english)
     
  15. Frozmat-Games

    Frozmat-Games

    Joined:
    Dec 17, 2012
    Posts:
    25
    New question. How do I configure ATG so that it can be used in cutscenes with multiple cameras? It seems that changing the camera does not work - the grass just don't rendered on the second camera. And every time the camera instantly changes its position or rotation the grass appears with a noticeable delay. This makes it impossible to use this asset in the cutscenes except when camera smoothly moves around the level. It is crucial for me.
     
    Last edited: Jul 21, 2018
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    it's no problem to have multiple cameras. multiple cameras rendering at the same time would need you to check "ignore visibility". but grass always get culled based on the camera tagged as camera.main (especially important if you use compute).
    if the 2nd the camera is not tagged as camera.main atg will not render anything.
    let's assume you have a dialogue and 2 cameras pretty close together but pointing into opposite directions. then using "Burst init" and a "Radius" of e.g. 50m should do the trick: this will make the grass manager immediately init all cells within the given radius around the current camera.main – regardless of the view direction.
    so when you switch to the 2nd camera the cells which are visible to this camera should already be initialized.
    In case you want to jump from camera a) in the small village to camera b) in the hills above the village, you could either use a giant radius (it is a cutscene, so memory usage might not be an issue here) or call burst init after you have switched to camera b) (which will give you a spike tho).
     
  17. Frozmat-Games

    Frozmat-Games

    Joined:
    Dec 17, 2012
    Posts:
    25
    It seems like culling calculates only from first camera world position (picture). So this option does not work and you still have to move the camera to a new position. Cutscenes does not done this way. You need to cut between camera motion.

    And it looks like something in this asset causes problems with "undo/redo". After "GrassManager" script is added to terrain, every time I try to do undo or redo operation takes from 1 to 2 seconds. And this "pauses between operations" is constantly increases reaching the state when the editor almost freezes. Any operation, move a cube, or change a parameter does not matter.
     

    Attached Files:

  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    you have enabled "compute" which culls grass per instance based on the frustum of the main camera -– which seems to be the first camera. so this will never work.
    and "render to all cameras" and "ignore visibility" does not mean that atg would cull the grass against all frusta – it means that the grass culled against the main camera's frustum will be drawn in all cameras.

    doing a cut scene i imagine that you have 2 cameras at different positions in the world, then switching between them by turning the first one off and the second one on thus the name "cut scene", right?
    so if you turn off the first camera and turn on the 2nd one (both tagged as main), atg will pick up the 2nd camera and perform culling according to this one. the now visible cells may not be initialized yet and may have to be generated, but calling burst init (from your script) should solve this.

    i never experienced anything like this – but i will have a look into this and see, if i can reproduce your issue.
     
  19. Frozmat-Games

    Frozmat-Games

    Joined:
    Dec 17, 2012
    Posts:
    25
    Okey, I will test it as you suggest.

    One more thing. Wind controller from "ATG" reacts to the timescale but the wind controller from the "AFS 5" does not. So that during "slowmotion" or pause in the game trees continue to move at normal speed. And do I really need to add both a "Setup Afs" script from "AFS 5" and the "Wind" script from "ATG" to control wind separately for grass and foliage?

    Aaaand one more thing.) It's not so important to me, but it can cause questions from others. It seams like "screen space reflections" from the unity "Post Processing Stack" somehow increase translucency or specular reflectivity (?) and colors are displayed distorted. In case of "AFS 5" it looks like ambient lighting or reflection underneath, but in case of "ATG" all colors are highly distorted.
     
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i did a quick test switching between 2 cameras. actually you have to set the "Cam" variable in the GrassManager to "null" to make it pickup the new camera.

    i have attached my simple test script. it will switch between 2 cameras when you hit "3".

    please note:
    you have to assign the 2 cameras as well as the grass manager (terrian) to the script.
    you will have to edit the grass manager script to make it work:
    find line 201:
    private AtgHiZBuffer HiZBuffer;
    and change it to:
    public AtgHiZBuffer HiZBuffer;
    unity will also complain about a compute buffer not being disposed properly – which i will fix asap.
     

    Attached Files:

  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    yes, you need both scripts. regarding afs i will have a look into it.

    well, they are simply broken :( due to the afs/atg gbuffer layout. but they look broken even if i use the stadard shaders and standard lighting and reflections shaders too. so i do not see the need to fix this.
     
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i can not confirm this. i have running unity and the grass manager now for more than an hour and undo just works as expected. which makes sense as in edit mode the grassmanager does not do anything.
     
  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    @Frozmat-Games btw: thanks a lot for coming up with this corner case i have not thought about yet!
     
  24. Frozmat-Games

    Frozmat-Games

    Joined:
    Dec 17, 2012
    Posts:
    25
    Well, that is strange. I checked it in a completely new project and the bug is still present. It also present in all demoscenes, so it's not that I do something wrong.

    Correction about wind and timescale. I was wrong, the foliage with AFS 5 shaders is also influenced by the timescale, but only in the game tab (window). And the animation remains consistent, there are no jumps in both tabs (windows) while timescale is tweaked. It looks like the plants are rendered twice. So It can be assumed that performance will increase after the build.
     
  25. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    indeed. i double checked it using Unity 5.6.3 and 2017.4 on win 10 pro and still can not confirm it.
     
  26. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    Getting a strange error from Grass Manager inspector in 2018.2.0f2:

    Code (csharp):
    1.  
    2. InvalidOperationException: Preview scene could not be created
    3. UnityEditor.PreviewScene..ctor (System.String sceneName) (at C:/buildslave/unity/build/Editor/Mono/Inspector/PreviewRenderUtility.cs:23)
    4. UnityEditor.PreviewRenderUtility..ctor () (at C:/buildslave/unity/build/Editor/Mono/Inspector/PreviewRenderUtility.cs:102)
    5. UnityEditor.MaterialEditor.Init () (at C:/buildslave/unity/build/Editor/Mono/Inspector/MaterialEditor.cs:1693)
    6. UnityEditor.MaterialEditor.DefaultPreviewGUI (Rect r, UnityEngine.GUIStyle background) (at C:/buildslave/unity/build/Editor/Mono/Inspector/MaterialEditor.cs:1899)
    7. UnityEditor.MaterialEditor.OnPreviewGUI (Rect r, UnityEngine.GUIStyle background) (at C:/buildslave/unity/build/Editor/Mono/Inspector/MaterialEditor.cs:1887)
    8. UnityEditor.Editor.OnHeaderIconGUI (Rect iconRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:751)
    9. UnityEditor.Editor.DrawHeaderGUI (UnityEditor.Editor editor, System.String header, Single leftMargin) (at C:/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:824)
    10. UnityEditor.MaterialEditor.OnHeaderGUI () (at C:/buildslave/unity/build/Editor/Mono/Inspector/MaterialEditor.cs:432)
    11. UnityEditor.Editor.DrawHeaderFromInsideHierarchy () (at C:/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:790)
    12. UnityEditor.Editor.DrawHeader () (at C:/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:656)
    13. AdvancedTerrainGrass.GrassManagerEditor.OnInspectorGUI () (at Assets/Packages/_AdvancedTerrainGrass/_Scripts/Editor/GrassManagerEditor.cs:429)
    14. UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor[] editors, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1374)
    This might be caused by 2018.2 limiting the number of preview scenes to 64 total and Grass Manager requiring many preview scenes to render the inspector or not deallocating them correctly.



    After that error is triggered, inspectors in many Editor contexts become broken until you restart the editor, since no new preview windows can be allocated.
     
    Last edited: Jul 24, 2018
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    thanks for pointing this out. i will have a look into it asap.
     
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    it seems to be the custom material inspector...
    so open the GrassManagerEditor.cs and find line:
    EditorGUIUtility.labelWidth = 0; // Rest Labelwith which get broken by the material inspector (around line 434)
    and add this line below:
    DestroyImmediate (_materialEditor);

    this fixes the issue for me in 2018.2.2.
     
  29. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    Thanks a lot, this helps!
     
  30. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    great.
     
  31. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    I got v1.09 and tried Compute. On my 2017 MBP with a Radeon 580 eGPU, I get (in the editor) about 90 fps in the Full Demo scene with Compute off, and 30 fps with Compute on. Would you expect that difference to be different in a build?

    And I'm confused about what the manual says about Compute. It says:

    Using compute on a GTX 970M and DX11 gave me significant performance improvements while using it on a GT 750M and Metal lowered my FPS.

    But the image right below that says that FPS increased on a GTX 750M from 220fps with Compute disabled to 380fps with Compute enabled. So I'm confused.

    It seems that there are possibly two factors that affect whether Compute helps or not: Strength of GPU, and Metal. Any guess which is (more) significant of a factor?

    thx
    Dave
     
  32. larsbertram1

    larsbertram1

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

    version 1.091 has been submitted.
    it ships with:
    • Added support for cutscenes and switching between cameras / teleporting.
    • Grass Manager Script: Fixed issues with (soft) merging layers.
    • Grass Manager Editor: Fixed issues with Unity 2018.2.
    meanwhile i am looking into adding some more content and best practice examples and playing around with a few assets from "book of the dead":

    botd_jpg.jpg
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    sorry, these numbers are taken from win 10 pro, dx 11 and gtx 970m.
    thanks for pointing this out.

    as you have tested on a 2017 MBP with a Radeon 580 eGPU i doubt it is the strength of the GPU as yours should be rather powerful.
    so it might be metal, unity's implementation of metal or just my bad compute shader code that does not work well on metal.
     
  34. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Thanks for the clarification. Yeah, Metal is the most plausible culprit.
     
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    or my bad compute shader :)
     
  36. franky_li

    franky_li

    Joined:
    Aug 8, 2016
    Posts:
    163
    Hi Lars,

    with the latest version the grass shader for Vegetation Studio is not working anymore in Unity 2018.1.6f1. Grass is not rendered, it just disappears.
     
  37. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i can not confirm this. i tested it with unity 2017.4 and 2018.2., latest vegetation studio and the shaders from atg 1.09.
    are you sure you have assigned the proper atg shaders for vs?
     
  38. franky_li

    franky_li

    Joined:
    Aug 8, 2016
    Posts:
    163
    I tested it again, grass disappears in the editor when changing the shader, but it's there in play mode. When I the quit play mode I can see it in the editor as well, but the icon for it in Vegetation Studio is empty. ATG.png
     
  39. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    fine!
    as discussed on the previous page of this thread: this is either caused by atg's wind or its culling. neither one would be easy to fix tho. but i will think about it.
     
  40. lo-94

    lo-94

    Joined:
    Nov 1, 2013
    Posts:
    282
    So I see that this has the Vegetation Studio logo on the asset store page but the description here says that runtime distributed grass is currently not supported. I'm looking for shaders to increase the quality of grass and plants which are created by vegetation studio. Which of your assets would you recommend for this? I saw vegetation studio is currently working on implementing 3rd party shader support for their pro version, but I'm not sure what they currently do/don't support or if this or your advanced foliage shader would work within a project with it

    I'd prefer rendering to be more on the gpu side as I like to save the cpu for AI and other computation heavy tasks
     
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    in case you use vs combined with atg, atg is just a shader. so you will get all benefits from vs plus atg shading on top.
    so if you are looking for better looking grass atg just should be fine.
     
  42. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    I'm getting some errors from GrassManager (on Mac with Unity 2017.1.7, Metal Editor but on Grass Manager, Compute is disabled because that's slower than normal on Macs, alas).

    With one terrain active:

    IndexOutOfRangeException: Index was outside the bounds of the array.
    AdvancedTerrainGrass.GrassManager.Init () (at Assets/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:799)
    AdvancedTerrainGrass.GrassManager.OnEnable () (at Assets/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:269)

    With several terrains with GrassManager active:

    IndexOutOfRangeException: Index was outside the bounds of the array.
    AdvancedTerrainGrass.GrassManager.Init () (at Assets/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:799)
    AdvancedTerrainGrass.GrassManager.OnEnable () (at Assets/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:269)

    Are these a concern? If so, any suggestions for them?
     
  43. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i never came across such an error. especially as it does not make much sense.

    in line 792 we declare:
    FinalLayersIndices = new int[OrigNumberOfLayers]
    then we use i < OrigNumberOfLayers as condition and write to FinalLayersIndices on line 799 – which errors for you. how could ever be greater then OrigNumberOfLayers?
     
  44. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    And I'm not using any layers! (Probably will once I have all the grass set up, but not yet.)
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    that all does not make any sense.
     
  46. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    @larsbertram1 A bit overwhelmed by my options... Using Vegetation Studio, looking for best performance and have been seeing ATG mentioned a lot, as well as your Advanced Foliage Shader. I watched your interview with Messy Coder - very informative but I'm still unclear whether I need to buy both assets.

    As far as I understand it...

    - grass instanced by VS should have its shader changed to ATG for even less load on the CPU (and better looking grass).
    [Is that 2D grass, 3D grass or both?]
    - trees and plants instanced by VS should have their shader changed to AFS so they can support instancing and wind (if the original assets did not - but no reason to do this with SpeedTree or NatureManufacture assets as these have shaders that already do instancing and wind)

    Is that correct? You do need both?
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    you do not need both.

    if you use vs and just want to have better looking grass you need atg.
    if you use vs and want to have better looking foliage (like ferns) and do not mind painting vertex colors manually in your 3d app (rbga tho) you can go with atg as well.

    if you want better looking foliage and would like to setup bending = vertex colors right within unity you would need afs – as it ships with a foliage tool.
    if you use unity tree creator trees and want pbr shading you would need afs as well.
     
    andreiagmu and jeromeWork like this.
  48. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    Thanks for that :) It's starting to make more sense

    Sounds as if I don't necessarily need both, but i should probably buy them both :D
     
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    well, i will not prevent you from buying both.
     
    jeromeWork likes this.
  50. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    Your love for what you do came across loud and clear on that messy coder interview, so I'm very glad to support a passionate and talented designer/dev.