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.
  2. Dismiss Notice

Question How to fix terrible shadow flickering in far distances?

Discussion in 'Editor & General Support' started by LastFractal, Jul 23, 2023.

  1. LastFractal

    LastFractal

    Joined:
    Mar 6, 2022
    Posts:
    25
    This issue has been driving me insane. Yes I tried increasing the camera near clipping and decreasing far clipping, neither of these worked. I played around with normal/depth bias, no help either. The flickering looks so terrible it's just impossible to ignore.

    Here's a recording, sorry for the garbage quality:


    I'm using 2022.3.5f1 with URP, I also use Cinemachine Virtual Camera.
     
  2. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    Doesn't look like shadow flickering but a bloom effect. Look at your postprocessing stack or possible other bloom effects.
     
  3. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    3,899
    Yeah that‘s not the normal flickering due to shadow texture size vs shadow distance mismatch. These shadows turn on and off entirely. Given the extreme noisy light bursts on the mountains it does seem there is something wrong with the graphics (quality) settings, postprocessing, culling or even the GPU (driver or hardware). I would check it in that order.
     
    KillDashNine likes this.
  4. LastFractal

    LastFractal

    Joined:
    Mar 6, 2022
    Posts:
    25
    I disabled bloom and the flickering was still there, then I decided to turn off all Post Processing elements, unfortunately that didn't fix it either.

    One thing I forgot to say is that the flickering only occurs when I build the game, there is no flickering while playing in the editor.

    I'm getting some shader errors during building, but I'm not sure if it has to do with "tree trunks":

    Shader warning in 'CTI/CTI URP SG Bark': 'multi_compile_vertex' : unknown pragma ignored at Bending.hlsl(1) (on d3d11)
    Compiling Subshader: 0, Pass: ShadowCaster, Vertex program with LOD_FADE_PERCENTAGE
    Platform defines: SHADER_API_DESKTOP UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_PASS_SHADOWCASTER UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS
    Disabled keywords: DOTS_INSTANCING_ON INSTANCING_ON SHADER_API_GLES30 UNITY_ASTC_NORMALMAP_ENCODING UNITY_COLORSPACE_GAMMA UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_RGBM_ENCODING UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_DXT5nm UNITY_NO_FULL_STANDARD_SHADER UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_VIRTUAL_TEXTURING _CASTING_PUNCTUAL_LIGHT_SHADOW


    Shader warning in 'CTI/CTI URP SG Bark': 'UnityMetaVertexPosition': implicit truncation of vector type at Code/Posthaste/Library/PackageCache/com.unity.render-pipelines.universal@14.0.8/Editor/ShaderGraph/Includes/Varyings.hlsl(131) (on d3d11)


    Shader warning in 'CTI/CTI URP SG Bark Array': 'multi_compile_vertex' : unknown pragma ignored at Bending.hlsl(1) (on d3d11)


    Another thing I forgot to add: my project is using DirectX12.
     
  5. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    I see, it's the trees that are shadow-flickering. The video quality is so packed that I can barely make out but that's what it looks like.

    Then I would definitely look for the issue in your tree shaders and those warnings look like a good spot. Looks like they relate to several HLSL shaders.
     
  6. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    3,899
    Also worth trying out Dx11 or Vulkan. If the issue persists you at least know it‘s not because of Dx12.
     
  7. LastFractal

    LastFractal

    Joined:
    Mar 6, 2022
    Posts:
    25
    Yeah, sorry for the video quality, I'm trying to record it on an APU.

    I tried removing trees and adding cube monoliths to see how shadows behave, they SEEMED fine however I doubt it because they're not detailed enough; they're just cubes.

    As for the shaders, I have no idea how to fix them. I'm kind of new to Unity.

    I've tried both, unfortunately that doesn't seem to fix it either.
     
    Last edited: Jul 23, 2023
  8. LastFractal

    LastFractal

    Joined:
    Mar 6, 2022
    Posts:
    25