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,898
    thanks!
     
  2. greyforest

    greyforest

    Joined:
    Jun 25, 2015
    Posts:
    16
    @larsbertram1
    "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."

    Means it does not support android?
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    i haven't tested it on android...
    vulkan of course should be able to run the shaders (like any other api which supports Graphics.DrawMeshInstancedIndirect and compute buffers) – but in general: aren't unity's terrain and grass still a bit too expensive for mobile?
     
  4. greyforest

    greyforest

    Joined:
    Jun 25, 2015
    Posts:
    16
    ES 3.1 minimum.Acceptable.I'll test it.
    Maybe add some switch so we can disable compute buffers,if it's not used in core feature?
     
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    there is already a checkbox to so so :)
    and i would be very interested in your findings.
     
  6. greyforest

    greyforest

    Joined:
    Jun 25, 2015
    Posts:
    16
    It's worked on android.But Quickstart Demo has only 10FPS on Qualcomm Snapdragon 660.No matter what Compute,Translucency Strength,cell batch was set.:(
     
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    and how many fps do you get if you deactivate the grass manager and let unity render the grass?
     
  8. greyforest

    greyforest

    Joined:
    Jun 25, 2015
    Posts:
    16
    11:(
    like someone else said in this thread before,other asset is even worse.
    on pc,every asset goes well,twice fps at least,but on lower end card,the builtin is better.
     
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    11 fps when using built in grass?
    10 fps when using atg?
    is that correct?

    in this case atg would not perform too bad: the quickstart demo is not optimized. and atg is mostly about avoiding spikes on the cpu. so you will get most benefits from it when the camera moves.
    if built in gives 11 fps and atg 10 fps then i think that the grass is just way too heavy for the gpu and you will have to decrease the intensity in order to get less overdraw.
     
  10. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,240
    Argh, something broke with ATG -- any ideas? Everything is set up correctly, can't figure out what went wrong. This is in a project where it was working fine a few weeks ago, haven't touched it since then AFAIK. On Unity 2018.1.7

    Screen Shot 2018-09-03 at 2.27.09 PM.png
     
    Last edited: Sep 3, 2018
  11. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,240
    And now I'm having a different problem in our main project (different from test project issue above). We moved up to 2018.2.6 (Mac) a few days ago, and now I'm getting a lot of weird errors in the console, and the Editor inspector gets messed up -- the Inspector panel is blank. Regularly happens when I click on the a prototype in the Grass Manager, and I can't repro it if I delete the Grass Manager from the terrain. See errors below. Any ideas what could be causing this or how to fix it?

    Attempting to open > 63 preview scenes, this is not supported, ensure you dispose of preview scenes properly
    UnityEditor.Editor:DrawHeader()
    AdvancedTerrainGrass.GrassManagerEditor:OnInspectorGUI() (at Assets/_AdvancedTerrainGrass/_Scripts/Editor/GrassManagerEditor.cs:429)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)



    InvalidOperationException: Preview scene could not be created
    UnityEditor.PreviewScene..ctor (System.String sceneName) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/PreviewRenderUtility.cs:23)
    UnityEditor.PreviewRenderUtility..ctor () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/PreviewRenderUtility.cs:102)
    UnityEditor.MaterialEditor.Init () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/MaterialEditor.cs:1698)
    UnityEditor.MaterialEditor.DefaultPreviewGUI (UnityEngine.Rect r, UnityEngine.GUIStyle background) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/MaterialEditor.cs:1904)
    UnityEditor.MaterialEditor.OnPreviewGUI (UnityEngine.Rect r, UnityEngine.GUIStyle background) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/MaterialEditor.cs:1892)
    UnityEditor.Editor.OnHeaderIconGUI (UnityEngine.Rect iconRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:758)
    UnityEditor.Editor.DrawHeaderGUI (UnityEditor.Editor editor, System.String header, System.Single leftMargin) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:831)
    UnityEditor.MaterialEditor.OnHeaderGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/MaterialEditor.cs:432)
    UnityEditor.Editor.DrawHeaderFromInsideHierarchy () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:797)
    UnityEditor.Editor.DrawHeader () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:663)
    AdvancedTerrainGrass.GrassManagerEditor.OnInspectorGUI () (at Assets/_AdvancedTerrainGrass/_Scripts/Editor/GrassManagerEditor.cs:429)
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor[] editors, System.Int32 editorIndex, System.Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1367)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)



    Expected top level layout group missing! Too many GUILayout.EndScrollView/EndVertical/EndHorizontal?
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)





    A PreviewRenderUtility was not clean up properly before assembly reloading which lead to leaking this scene in the Editor. This can be caused by not calling Cleanup() during the OnDisable of an Editor or an EditorWindow.
    UnityEditor.PreviewRenderUtility:Finalize()



    GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)




    InvalidOperationException: Preview scene could not be created
    UnityEditor.PreviewScene..ctor (System.String sceneName) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/PreviewRenderUtility.cs:23)
    UnityEditor.PreviewRenderUtility..ctor () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/PreviewRenderUtility.cs:102)
    UnityEditor.MaterialEditor.Init () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/MaterialEditor.cs:1698)
    UnityEditor.MaterialEditor.DefaultPreviewGUI (UnityEngine.Rect r, UnityEngine.GUIStyle background) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/MaterialEditor.cs:1904)
    UnityEditor.MaterialEditor.OnPreviewGUI (UnityEngine.Rect r, UnityEngine.GUIStyle background) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/MaterialEditor.cs:1892)
    UnityEditor.Editor.OnHeaderIconGUI (UnityEngine.Rect iconRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:758)
    UnityEditor.Editor.DrawHeaderGUI (UnityEditor.Editor editor, System.String header, System.Single leftMargin) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:831)
    UnityEditor.MaterialEditor.OnHeaderGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/MaterialEditor.cs:432)
    UnityEditor.Editor.DrawHeader () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:665)
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor[] editors, System.Int32 editorIndex, System.Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1230)
    UnityEditor.InspectorWindow.DrawEditors (UnityEditor.Editor[] editors) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1126)
    UnityEditor.InspectorWindow.OnGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:481)
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <f2e6809acb14476a81f399aeb800f8f2>:0)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <f2e6809acb14476a81f399aeb800f8f2>:0)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <f2e6809acb14476a81f399aeb800f8f2>:0)
    UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:295)
    UnityEditor.HostView.Invoke (System.String methodName) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:288)
    UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:261)
    UnityEditor.DockArea.OldOnGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:392)
    UnityEngine.Experimental.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, System.Boolean isComputingLayout) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:238)
    UnityEngine.Experimental.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:376)
    UnityEngine.Experimental.UIElements.IMGUIContainer.DoRepaint (UnityEngine.IStylePainter painter) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:88)
    UnityEngine.Experimental.UIElements.Panel.PaintSubTree (UnityEngine.Event e, UnityEngine.Experimental.UIElements.VisualElement root, UnityEngine.Matrix4x4 offset, UnityEngine.Experimental.UIElements.VisualElement+ClippingOptions clippingOption, UnityEngine.Rect currentGlobalClip) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Panel.cs:732)
    UnityEngine.Experimental.UIElements.Panel.PaintSubTreeChildren (UnityEngine.Event e, UnityEngine.Experimental.UIElements.VisualElement root, UnityEngine.Matrix4x4 offset, UnityEngine.Experimental.UIElements.VisualElement+ClippingOptions clippingOption, UnityEngine.Rect textureClip) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Panel.cs:748)
    UnityEngine.Experimental.UIElements.Panel.PaintSubTree (UnityEngine.Event e, UnityEngine.Experimental.UIElements.VisualElement root, UnityEngine.Matrix4x4 offset, UnityEngine.Experimental.UIElements.VisualElement+ClippingOptions clippingOption, UnityEngine.Rect currentGlobalClip) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Panel.cs:736)
    UnityEngine.Experimental.UIElements.Panel.Repaint (UnityEngine.Event e) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Panel.cs:778)
    UnityEngine.Experimental.UIElements.UIElementsUtility.DoDispatch (UnityEngine.Experimental.UIElements.BaseVisualElementPanel panel) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:227)
    UnityEngine.Experimental.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:74)
    UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:171)
     
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    it looks like the shader is broken.
     
  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    if i remember properly this is an "old" problem with 2018 - which was fixed at least in the latest version of atg.
    so which one do you use tin the project?
     
  14. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,240
    Thanks, I updated ATG and both problems are fixed, sorry, I should've checked the release notes.
     
  15. SkandYxyz

    SkandYxyz

    Joined:
    Mar 13, 2015
    Posts:
    83
    Hi,

    i have a problem with an offset of displayed grass. scr3.png
    Why can this happen?

    Another problem I face is, that performance is very bad in compaison to unity grass. With Unity Grass I can display grass with a deail distance of 250 at 60FPS. With ATG its only 10FPS.

    Best,
    Andre

    Edit:
    When I reset grass sizes from 8 to 1 it is fixed.
     
    Last edited: Sep 29, 2018
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    hi there,
    hmm, i do not really see the problem, sorry. maybe you can take a screen capture?
    ups. have you been following the docs on how to optimize performance? like using 2 step culling and merging (soft merging) layers?
    also do you use compute?
    how many details have you added to the terrain?
    and which platform are you on?
     
  17. SkandYxyz

    SkandYxyz

    Joined:
    Mar 13, 2015
    Posts:
    83
    Hi again,

    the problem was, that the radius of displayed grass was not centered at camera, when i set the grass size in unity terrain grass settings between 8 and ten. i resolved it by putting the size back to 1-2 and creating a bigger grass mesh in max.
    anyhow, did not yet use 2 step culling and merging. I enabled instancing in material, but what do you mean by compute? is it also described in the manual? the terrain's grass patch size is 8 and full of grass. platform windows 7, unity 5.6.0f3. Below you can see the comparison between grass manager deactivated and below activated. with unity grass i get around 60fps.
    scr5.png scr6.png

    Edit:
    Below unity grass and a bit of atg on the right terrain. Even 72FPS.
    scr6.jpg
     
    Last edited: Sep 29, 2018
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    well, this is pretty important regarding performance.
    using a compute shader to cull the grass. further details are in the docs.
    you should at least upgrade to unity 5.6.3. anything < unity 5.6.3. will slow down drawmeshinstancedindirect.
    please have a look at the "setpass calls": 568 with unity grass and 2315 using atg. that means that atg produces a vast amount of draw calls – either because your cell size is too small (derived from "buckets per cell") or you have a lot of different prototypes (although it does not look so). so try to increase the number of buckets per cell.
     
  19. FalconCGN

    FalconCGN

    Joined:
    Jan 18, 2014
    Posts:
    33
    Hi I have an open world with hundreds of terrain chunks, so it is not really possible to manually click on "Save TerrainData" for every chunk. Any ideas?
     
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    hmm, i guess creating these chunks takes way more time to generate and fill than hitting "safe terraindata".
    but if it is all automated and procedural you may have a look into the grassmanagereditor script and copy/paste the function into your automatization process.
     
  21. FalconCGN

    FalconCGN

    Joined:
    Jan 18, 2014
    Posts:
    33
    Hi Lars,

    thanks for the quick reply.

    Well I guess I have to. I tried to add an OnEnable() method in the GrassManagerEditor Script and added a SaveTerrainData() to it. But this did not work.

    Curretly I also have an error that grass is not rendering at all.
    MainCamera is there, Directional light is there, ATG Wind Prefab exists,
    The grass density is set to 0,32 on the Terrain component, so this is used for "Grass Density" in the Grass Manager.
    If I set Grass Density to 1 and deactivate and activate the Script again it works.
    This looks like a bug though.

    When I activate Compute I am getting this error
    NullReferenceException: Object reference not set to an instance of an object
    AdvancedTerrainGrass.GrassManager.DrawGrass () (at Assets/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:1156)
    AdvancedTerrainGrass.GrassManager.LateUpdate () (at Assets/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:306)

    When I activate floating origin
    NullReferenceException: Object reference not set to an instance of an object
    AdvancedTerrainGrass.GrassManager.DrawGrass () (at Assets/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:1093)
    AdvancedTerrainGrass.GrassManager.LateUpdate () (at Assets/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:306)

    Best
    Sebastian
     
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    this has to be checked before you enter playmode.
    this one as well.
    0.3 just may be too small - or do you get any errors?
    what is about 0.75 or 0.5?
     
  23. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    Hi @larsbertram1, Ive got most of your shaders for foliage (AFS,AFG,CTI) but I was just wondering if you have a simple bark shader that uses instanced indirect and has simple wetness. Same for simple grass/plants that have a simple wetness feature and is instanced indirect compatible.

    Cheers Andy
     
  24. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    that would be an entire system of shaders :)
    you may have a look into my free Lux asset: it comes with simple and complex wetness functions which could be added to afs, atg or cti.

    instanced indirect then comes from vs i guess.
     
    AndyNeoman likes this.
  25. FalconCGN

    FalconCGN

    Joined:
    Jan 18, 2014
    Posts:
    33
    Hi Lars,

    with > 0.5 it works. But only if I add the script manually. If I stream scenes with the script attached to the terrain it will just not render unless I disable the grass manager manually and manually enable it again.

    If I try the same thing via script it does not work.
    I would really love to use the script, because it is great. Only grass is a little too light.

    Best
    Sebastian
     
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    strange, but why do you not call the grass manager's init function?
     
  27. FalconCGN

    FalconCGN

    Joined:
    Jan 18, 2014
    Posts:
    33
    I did, same thing. We always get an error on LayerToMergeWith.GetArrayElementAtIndex(i) and it stops executing. Both on Editor script and on the GrassManager.cs. Only on initial load though.
     
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    try to comment:
    v_mesh = null;
    v_mat = null;
    in the grass manager script. around line 378 in the OnDisable()
     
  29. FalconCGN

    FalconCGN

    Joined:
    Jan 18, 2014
    Posts:
    33
    Hi, we found a workaround: the size of LayerToMergeWith is wrong during initial load. So we wait for initial load and then select the Editor-GUI via script again. Then it works without an error and we can call SaveTerrainData()
     
    Last edited: Oct 18, 2018
  30. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    i am a bit confused – as i thought we were talking about streamed in terrain not showing up grass...
    nevermind. i am glad, that you work a workaround!
     
  31. FalconCGN

    FalconCGN

    Joined:
    Jan 18, 2014
    Posts:
    33
    Yes we are. But we had to save/bake the result in the editor first.
    One thing remains though:

    GarbageCollector disposing of ComputeBuffer allocated in Game\Src\Assets\_AdvancedTerrainGrass\_Scripts\GrassManager.cs at line 485. Please use ComputeBuffer.Release() or .Dispose() to manually release the buffer.
    UnityEngine.ComputeBuffer:Finalize()

    This happens although we do not use compute.


    Also, we sometimes have some trouble with flying grass when we change for example the density and then call Init(). Do you have ideas?
     
    Last edited: Oct 19, 2018
  32. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    drawmeshinstancedindirect always involves a compute buffer (argsBuffer):
    https://docs.unity3d.com/ScriptReference/Graphics.DrawMeshInstancedIndirect.html
    you should not call Init() unless you have cleaned up everything first. have a look at OnDisable (but do not clear v_mat and v_mesh). but in order to change density you do not have to call Init(). call RefreshGrassRenderingSettings() instead.
     
  33. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    I will take a look at lux thanks. It might have looked like I was asking for the earth but i just wondered if one of the packages already contained it and I just didn't notice :). I have already added your complex rain to the cti leaves shader and it works a treat but with grass/bark i want something simpler and cheaper - I will check out lux, If you could you point in the right direction that would be great.
     
  34. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    lux comes with a bunch of predefined macros you can use – although if you have already added the complex rain from afs to cti leaves it would be more simple to just take this code and remove the code for sampling the rain drops.
     
    AndyNeoman likes this.
  35. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    @larsbertram1 Are there any shader model requirements for this? I'd like to try on Wii U, but am worried it won't work there.

    [EDIT]
    I see you mention that it uses instancing to render so I guess that means Wii U won't work. But if that's not correct then let me know.
     
    Last edited: Oct 19, 2018
  36. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    it even uses indirect instancing...
     
  37. FalconCGN

    FalconCGN

    Joined:
    Jan 18, 2014
    Posts:
    33
    Ok, now I am always getting an error after around 20 Minutes
    d3d11: failed to create 2D texture shader resource view id=1932981 [D3D error was 887c0003]
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    hmm, i never heard about something like this.
    do you have any more details?
     
  39. FalconCGN

    FalconCGN

    Joined:
    Jan 18, 2014
    Posts:
    33
    Never mind. That was a different problem. But thank you anyway.
     
  40. LumaPxxx

    LumaPxxx

    Joined:
    Oct 3, 2010
    Posts:
    340
    hi,lars,did you tried ATG in unity3d 2018.2.1x?

    i tried both in 2018.2.14 and 2.15.

    it is so unstable in 2018.2.1x,all the grass disappear and pop out so randomly(not one cell but all).

    i tried what you said "Check Ignore Visibility" or close editor scene tab and check the camera is maincamera.

    nothing worked and no error report in console.

    i have never got such a problem in unity 2017.3.

    Edit:
    sorry,it's my bad.
    i tried to represent it in new project and figure out it only happens on very small terrain (exp:30m*30m terrain).
     
    Last edited: Nov 18, 2018
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    i am running it in 2018.2.15f1 without any problems.
    ah, yes. i guess these smalll teerains wuld need some me safeguards.
    it might also be the culling spheres. anyway: terrain sizes > 100m should be fine (deatil resolution should be >= 256).
     
  42. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,240
    I've been having some problems with ATG grass not spawning at runtime. I get a rapidly repeating error in the console:

    ArgumentNullException: Value cannot be null.
    Parameter name: material
    UnityEngine.Graphics.DrawMeshInstancedIndirect (UnityEngine.Mesh mesh, System.Int32 submeshIndex, UnityEngine.Material material, UnityEngine.Bounds bounds, UnityEngine.ComputeBuffer bufferWithArgs, System.Int32 argsOffset, UnityEngine.MaterialPropertyBlock properties, UnityEngine.Rendering.ShadowCastingMode castShadows, System.Boolean receiveShadows, System.Int32 layer, UnityEngine.Camera camera, UnityEngine.Rendering.LightProbeUsage lightProbeUsage, UnityEngine.LightProbeProxyVolume lightProbeProxyVolume) (at /Users/builduser/buildslave/unity/build/Runtime/Export/Graphics.cs:503)
    UnityEngine.Graphics.DrawMeshInstancedIndirect (UnityEngine.Mesh mesh, System.Int32 submeshIndex, UnityEngine.Material material, UnityEngine.Bounds bounds, UnityEngine.ComputeBuffer bufferWithArgs, System.Int32 argsOffset, UnityEngine.MaterialPropertyBlock properties, UnityEngine.Rendering.ShadowCastingMode castShadows, System.Boolean receiveShadows, System.Int32 layer, UnityEngine.Camera camera) (at /Users/builduser/buildslave/unity/build/Runtime/Export/Graphics_BindingsOverloads.cs:288)
    AdvancedTerrainGrass.GrassCellContent.DrawCellContent_Delegated (UnityEngine.Camera CameraInWichGrassWillBeDrawn, System.Int32 CameraLayer, UnityEngine.Vector3 TerrainShift) (at Assets/_AdvancedTerrainGrass/_Scripts/Classes/GrassCellContent.cs:126)
    AdvancedTerrainGrass.GrassManager.DrawGrass () (at Assets/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:1230)
    AdvancedTerrainGrass.GrassManager.LateUpdate () (at Assets/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:306)


    Toggling the Grass Manager off and does not help. Sometimes toggling the terrain itself off and on does get the grass to spawn, but not always -- and when I do that, I get some more errors:

    NullReferenceException: Object reference not set to an instance of an object
    AdvancedTerrainGrass.GrassManager.BurstInit () (at Assets/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:1007)
    AdvancedTerrainGrass.GrassManager.Init () (at Assets/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:961)
    AdvancedTerrainGrass.GrassManager.OnEnable () (at Assets/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:265)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    NullReferenceException: Object reference not set to an instance of an object
    AdvancedTerrainGrass.GrassManager.DrawGrass () (at Assets/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:1311)
    AdvancedTerrainGrass.GrassManager.LateUpdate () (at Assets/_AdvancedTerrainGrass/_Scripts/GrassManager.cs:306)


    Any suggestions?

    thanks
    Dave
     
  43. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    it looks as if one of the materials is missing...
     
  44. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,240
    D'oh! Thanks!
     
  45. AHFontaine

    AHFontaine

    Joined:
    Aug 3, 2017
    Posts:
    19
    Hi! I gave a try with using this on 2018.3.0b10.
    Weirdly enough, the color is completely different than the one used (Full Demo shows it as Red). I gave a try in case terrain's grass is broken but color-wise, it's fine.
    Is it compatible with 2018.3b yet or nah?
     
  46. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    i checked the full demo in unity 2018.3.0b11 on windows and DX11: everything here looks as expected.
    if you get weird colors (grass is red), than you have to assign the atg deffered lighting and reflection shaders like described in the docs.
    in order to do a quick test you can just set the camera from deferred to forward.
     
  47. AHFontaine

    AHFontaine

    Joined:
    Aug 3, 2017
    Posts:
    19
    Thank you for your quick reply!
    That did it on this aspect.
    Now, I have another question regarding the cameras : I'm doing a full dome project where the cameras are set in a cam rig to give a 360 view (210 degrees of a sphere). It consists of 5 cameras sending to render textures which are then filmed by an orthographic camera.
    I noticed that putting all cameras as main camera (except the orthographic one) will result in only one rendering the grass, I might be setting it wrong but, I wonder : does ATG support multi-cam setups?
     
  48. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    i have never looked into multi-cam support...
    so right out of my mind i think there are 2 things that will break it:
    • culling groups which are used to cull the "visible cells". you should check "ignore visibility". most likely you even have to change the grass manager script...
    around line 876 you will find a 2nd visibility test: just comment all the following lines.
    Code (CSharp):
    1. if(IngnoreOcclusion) {
    2.                     if (isVisibleBoundingSpheres[ resultIndices[i] ] == false)
    3.                         continue;
    4. }
    • compute uses HiZ culling. so it relies on the depth buffer of only one camera of course... so you have to disable compute.
    then one camera tagged as main camera should be fine. it is just needed to get a reference point for the culling spheres and set some shader variables to fade out the grass over distance.
     
  49. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    Does ATG play well with Vegetation Studio Pro?
     
  50. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    i only tested the "regular" version, sorry.