HDRP Terrain Details Flickering

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?

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.

1 Like

I’ll look into it, thank you for the help!

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?

Could you take a video of the issue

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:

DivideByZeroException: Attempted to divide by zero.
UnityEditor.TerrainInspector.GetAspectRect (System.Int32 elementCount, System.Int32 approxSize, System.Int32 extraLineHeight, System.Int32& itemsPerRow) (at <5700f1e4d61f4c96b68ca2ee3cdd8eae>:0)
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)
UnityEditor.TerrainTools.PaintDetailsTool.OnInspectorGUI (UnityEngine.Terrain terrain, UnityEditor.TerrainTools.IOnInspectorGUI editContext) (at <5700f1e4d61f4c96b68ca2ee3cdd8eae>:0)
UnityEditor.TerrainInspector.ShowDetails () (at <5700f1e4d61f4c96b68ca2ee3cdd8eae>:0)
UnityEditor.TerrainInspector.OnInspectorGUI () (at <5700f1e4d61f4c96b68ca2ee3cdd8eae>:0)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass62_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <68628848f6e642b6b06ef341bae611b2>:0)
UnityEditor.InspectorWindow:RedrawFromNative()

Looks like something may be wrong with the terrain itself in some way.

https://www.youtube.com/watch?v=f5zLek_TYUA

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.

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.

1 Like

Also – is it possible for you to switch to DirectX 11 and see if the issue still occurs?

1 Like

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.

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.

DX12 in HDRP doesn’t really give better performance, it’s slower than DX11. Not sure about DX12 with other render pipelines.

1 Like

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.

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.

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? :smile:

1 Like

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.

1 Like

Yeah, if just someone would read the forum :smile:
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.

1 Like

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

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.