Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug HDRP Terrain Details Flickering

Discussion in 'World Building' started by ThatProgrammerJack, Jun 5, 2022.

  1. ThatProgrammerJack

    ThatProgrammerJack

    Joined:
    Jan 6, 2019
    Posts:
    30
    Hi there. I’m using HDRP in the latest version of Unity 2022, and I’m painting details onto my terrain. These details use grass prefabs from Unity’s HDRP Terrain Demo Scene, and they are GPU-instanced. Also, I’m using DirectX 12 within Unity.

    The issue is that these details badly flicker. I can’t seem to find the source of the problem. Any ideas?
     
  2. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,081
    Could be temporal antialiasing. Go to your camera and disable anti-aliasing, and see if it still flickers once in-game.
    Also scene camera has it's own anti-aliasing setting, you can find it by pressing on the small camera icon.

    Temporal Antialiasing does worse on vegetation that is rendered through unity's terrain, (since it uses instancing), and so they lose motion vectors which TAA relies on to produce better results.
     
    ThatProgrammerJack likes this.
  3. ThatProgrammerJack

    ThatProgrammerJack

    Joined:
    Jan 6, 2019
    Posts:
    30
    I’ll look into it, thank you for the help!
     
  4. ThatProgrammerJack

    ThatProgrammerJack

    Joined:
    Jan 6, 2019
    Posts:
    30
    Tried it out, disabled TAA on both scene and main camera. Did not seem to work. I'm trying enabling the detail objects for lightmapping, maybe that'll help. Any other ideas?
     
  5. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,081
    Could you take a video of the issue
     
  6. ThatProgrammerJack

    ThatProgrammerJack

    Joined:
    Jan 6, 2019
    Posts:
    30
    Tried it out, disabled TAA on both scene and main camera. Did not seem to work. I'm trying enabling the detail objects for lightmapping, maybe that'll help. I did, however, just notice this error, could be related:

    Code (CSharp):
    1. DivideByZeroException: Attempted to divide by zero.
    2. UnityEditor.TerrainInspector.GetAspectRect (System.Int32 elementCount, System.Int32 approxSize, System.Int32 extraLineHeight, System.Int32& itemsPerRow) (at <5700f1e4d61f4c96b68ca2ee3cdd8eae>:0)
    3. UnityEditor.TerrainInspector.AspectSelectionGridImageAndText (System.Int32 selected, System.Int32 itemCount, UnityEngine.GUI+CustomSelectionGridItemGUI itemGUI, System.Int32 approxSize, UnityEngine.GUIContent emptyString, System.Boolean& doubleClick) (at <5700f1e4d61f4c96b68ca2ee3cdd8eae>:0)
    4. UnityEditor.TerrainTools.PaintDetailsTool.OnInspectorGUI (UnityEngine.Terrain terrain, UnityEditor.TerrainTools.IOnInspectorGUI editContext) (at <5700f1e4d61f4c96b68ca2ee3cdd8eae>:0)
    5. UnityEditor.TerrainInspector.ShowDetails () (at <5700f1e4d61f4c96b68ca2ee3cdd8eae>:0)
    6. UnityEditor.TerrainInspector.OnInspectorGUI () (at <5700f1e4d61f4c96b68ca2ee3cdd8eae>:0)
    7. UnityEditor.UIElements.InspectorElement+<>c__DisplayClass62_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <68628848f6e642b6b06ef341bae611b2>:0)
    8. UnityEditor.InspectorWindow:RedrawFromNative()
    9.  
    Looks like something may be wrong with the terrain itself in some way.
     
  7. ThatProgrammerJack

    ThatProgrammerJack

    Joined:
    Jan 6, 2019
    Posts:
    30
     
  8. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,081
    Yeah that's weird, no way that's caused by anti-aliasing method. Not sure what to be honest.
    Most likely as you said it's a problem with the terrain.

    Try disabling/enabling instancing in terrain settings, see if that changes anything.
    Also try disabling all post processing.
    Finally try disabling Light Layers in your active HDRP asset (the one your using). It's there somewhere.

    If the issue still occurs it's most likely an issue with the terrain or grass shader, not sure what unfortunately.
     
  9. mattb-unity

    mattb-unity

    Unity Technologies

    Joined:
    Feb 7, 2020
    Posts:
    34
    Are you using default shaders or something you've creating with ShaderGraph? Also interested to know the results of testing with GPU instancing turned off.

    If you have a project where you can reproduce the issue reliably (seems like this is the case) I'd say go ahead and created a bug report and we'll take a look.
     
    ThatProgrammerJack likes this.
  10. mattb-unity

    mattb-unity

    Unity Technologies

    Joined:
    Feb 7, 2020
    Posts:
    34
    Also -- is it possible for you to switch to DirectX 11 and see if the issue still occurs?
     
    ThatProgrammerJack likes this.
  11. ThatProgrammerJack

    ThatProgrammerJack

    Joined:
    Jan 6, 2019
    Posts:
    30
    It looks like it's from a TerrainGrass shader graph, but I didn't create it myself. I'm using grass details from Unity's HDRP Terrain Demo Scene. Also, disabling GPU instancing appears to be unsupported. Unity version is 2022.1.2f1, HDRP version is 13.1.8.
     
  12. ThatProgrammerJack

    ThatProgrammerJack

    Joined:
    Jan 6, 2019
    Posts:
    30
    Fortunately, it looks like switching to DX11 worked. Unfortunately, looks like I can't reap the performance benefits of DX12. Thank you for suggesting that, though, and I guess I can finally get on with my project.
     
  13. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,081
    DX12 in HDRP doesn't really give better performance, it's slower than DX11. Not sure about DX12 with other render pipelines.
     
    ThatProgrammerJack likes this.
  14. mattb-unity

    mattb-unity

    Unity Technologies

    Joined:
    Feb 7, 2020
    Posts:
    34
    Thanks for following up! Of course we don't want DX12 to be broken so this will need to get fixed. If you have a project that reproduces the issue reliably, a bug report with said project would be awesome.
     
  15. KrystofZacek

    KrystofZacek

    Joined:
    Jul 28, 2020
    Posts:
    7
    I have the same problem on URP. A grass mesh from the latest Unity's Terrain Sample Asset Pack flickers in Game mode (both shadow and the grass) as if it was Z-fighting with itself. Nothing helps (DX11/12, shadow bias, near clipping plane etc). The grass comes with shader "Shader graphs\Terrain grass". In Scene mode the flickering does not occur. Interestingly in a new clean project I cannot reproduce it.
     
  16. ashtorak

    ashtorak

    Joined:
    Feb 19, 2014
    Posts:
    53
    Seems, this didn't get fixed yet, if it's a bug? It's still happening for me in 2022.2.b13 with the latest version of the HDRP Terrain demo. Flickers on DX12 but not 11. I can make a bug report, if necessary. But it seems pretty easy to reproduce and shouldn't happen now with DX12 out of experimental. Especially not on an Unity demo. Or is there some secret HDRP setting that you have to tick to have it work in DX12? :D
     
    ThatProgrammerJack likes this.
  17. ThatProgrammerJack

    ThatProgrammerJack

    Joined:
    Jan 6, 2019
    Posts:
    30
    Good to see the thread is still getting attention. I've been done with the project for about eight months now but it's a little frustrating that DX12, for all its wonderful performance benefits, still has issues with a pretty significant component of the terrain system. I'm building a space game rn but I still hope it gets resolved, and soon.
     
    ashtorak likes this.
  18. ashtorak

    ashtorak

    Joined:
    Feb 19, 2014
    Posts:
    53
    Yeah, if just someone would read the forum :D
    Anyway, I have just submitted a bug report and will keep you updated here on how's it going. That's what I wrote on how to reproduce it:

    Start a HDRP core project, import Unity HDRP Terrain Sample Asset and start the TerrainDemoScene while using DX12.
    Move the camera in scene view and you see flickering of the grass already. Same happens in play mode.
    If you turn DX12 off and use DX11, there is no flickering.
     
    wyattt_ likes this.
  19. ashtorak

    ashtorak

    Joined:
    Feb 19, 2014
    Posts:
    53
    Yay! It's under review:

    Description

    How to reproduce:
    1. Open the project “IN_24945”
    2. In the Hierarchy select “Main Camera” GameObject

    Expected result: no flickering in the Scene view
    Actual result: flickering in the Scene view

    Reproducible with: 2022.1.2f1, 2022.2.0b16
    Not reproducible with: 2021.3.16f1, 2022.2.0f1, 2022.2.2f1, 2023.1.0a24
    Couldn’t test with: 2022.1.1f1 (due to the project crashing after selecting DX12 Graphics API)

    Reproducible on: Windows 10 Pro

    Note:
    - also reproducible in the Play Mode
    - couldn’t test on Player due to failed build
     
  20. Snigros

    Snigros

    Joined:
    Jun 12, 2018
    Posts:
    31
    Also experiencing this issue (or something with the same symptoms anyway) with 2021.3.16f1 and URP 12.1.8. I do not have the option of reverting to DX11 as I need DX12 for the Crest Ocean System to render properly on XBox. Is there a link/reference number for the bug report mentioned in the last post above? Thanks.
     
  21. ashtorak

    ashtorak

    Joined:
    Feb 19, 2014
    Posts:
    53
    No update yet, it's still in review. I moved on to 2023.1.0a25 where it doesn't flicker.

    Update: It landed on the issue tracker https://issuetracker.unity3d.com/is...cene-and-game-view-when-using-hdrp-demo-scene
     
    Last edited: Jan 24, 2023
  22. Snigros

    Snigros

    Joined:
    Jun 12, 2018
    Posts:
    31
    ashtorak likes this.
  23. ashtorak

    ashtorak

    Joined:
    Feb 19, 2014
    Posts:
    53