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

Bug Shadows went bananas (low resolution & flickering problem)

Discussion in 'High Definition Render Pipeline' started by NathanAlejver, Jan 27, 2023.

  1. NathanAlejver

    NathanAlejver

    Joined:
    Feb 14, 2017
    Posts:
    4
    Hello!
    I've got problem with shadow quality in my Unity (2021.3.15f1) with HDRP. I've got a big interior scene - couple of rooms and corridors with realtime point lights. Unfortunately, the shadows seem to be very pixelated and low quality (even though everything is set to max), and what's more, they seem to flicker (see gif animation). I can't really find any solution on web, so I decided to post my issue here.

    My settings:
    - HDRP Settings: Shadow filtering quality is set to high in HDRP component
    - Assets: All 3D objects are set to static and have proper 1:1:1 scale and uses a set of 4096x4096 materials. Most of them cast shadows (set as static shadow caster) and are located no further than 100 units from the center of scene.
    - Camera: Clipping Planes value - near: 0.1, far: 33), so it's very limited.
    - Lights: There are 19 static point lights on the scene (yet most of them remain culled and problem happens even if there are just few point lights active) and all of them cast shadows with poor resolution.

    My observations:
    - when I set camera Clipping Planes to ridiculously low value (far: 1), the problem disappears (shadows no longer flicker, but are still very low quality).
    - when I disable 90% of content in my scene, the issue seems to vanish. Yet, it's not caused by just one single buggy object. Maybe Unity just can't handle big interior scenes with realtime lighting?
    - the more point light there are, the more pixelated their shadows are
    - there are no errors in console

    I'll be grateful for your help in figuring this out or finding a different possible solution. Thank you.
     

    Attached Files:

    Last edited: Jan 28, 2023
  2. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    Are your point light shadows set to update every frame?
    Try to disable some point lights in the scene, do shadows improve when you do that?
    Finally, try setting shadow filtering quality to medium.

    High requires TAA for denoising, it's also a lot more expensive for point lights, and sampling costs will be expensive on high filtering and can't be cached. It also needs refresh mode enabled in the scene view, otherwise it'll look noisy.
     
  3. NathanAlejver

    NathanAlejver

    Joined:
    Feb 14, 2017
    Posts:
    4
    Thanks for the suggestion, setting shadow filtering quality to medium helped to make them look smooth, more natural and game runs faster. Yet, they still flicker regardless of quality (or active shadow casters).

    – I've tried disabling some pointlights and luckily shadows stop flickering, so the problems happens only when there are too many pointlights on scene (but are 10-20 really too much? Especially as half of them shouldn't be visible anyway, seems to be rather bug than overkill, especially that FPS is high and stable). I've also noticed Unity probably renders even obscured pointlights as floating dots in the middle of nowhere, as if I disable distant pointlights in occluded areas reduces the amount of flickering, which is very strange (see gif example)
    – I've also set "Anti-flickering” (camera TAA settings) to max. It helped to reduce this effect, but it's bruteforce solution and didn't solve it, it's still visible.
    – All lights use use "Every Frame" update mode as I'm not familiar with "On enable" mode and after trying to set it, I got problems with shadow atlas resolution, glitches and framerate loss, I don't know if I setup it correctly, but I'm not sure if it's good solution.

    The problem is easy to replicate by running the default HDRP sample scene and copy-pasting shadow casting lights, as mentioned in similar issue. The more lights there are, the more flickery they are.
     

    Attached Files:

    JackPotato likes this.
  4. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    703
    You might also want to look at the shadow atlas size for punctual lights.
    Once the atlas is full, additional lights will force to reduce the resolution of all shadowmaps to fit in the atlas.
     
  5. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    I tried reproducing this myself:


    Increasing maximum shadows on screen seems to fix it.
    A single point light with shadows enabled generates six shadows, so it seems you can get over 128 (the default) pretty quickly if you use many shadowed point lights.

    This is the warning I get when there's too many point light shadows and this starts happening:
    upload_2023-1-30_19-27-11.png
     
  6. NathanAlejver

    NathanAlejver

    Joined:
    Feb 14, 2017
    Posts:
    4
    Thanks for reply, but that's not exactly this kind of issue. In my project, shadows are not blinking like they're fighting for it's presence on a scene, but rather "waving" like somebody holding a torch. I'm not getting this warning and I guess my maximum shadows value is big enough (tried on 512,1024 and bigger ones, no success).

    The easiest way to reproduce this is starting new HDRP sample scene from Unity and duplicating some lights a few times.
     
    Last edited: Jan 30, 2023
  7. JackPotato

    JackPotato

    Joined:
    Jul 16, 2018
    Posts:
    7
    I don't suppose you found a solution for this? I'm currently facing the exact same issue.

    Real-time point lights. Occlusion Culling + Portals for doors. Tried disabling distant ones and got the exact result you posted. Occlusion Culling really doesn't seem to take real-time lights into account. Even getting shadow/light bleed when using 10-20 point lights to light up my building scene.

    Currently need to bump up the resolution from 2048 to the max 16384 before the flickering eventually stops - not very sustainable...
     
  8. NathanAlejver

    NathanAlejver

    Joined:
    Feb 14, 2017
    Posts:
    4
    Hi, unfortunately there's no solution, sorry. But there is a workaround that helped me a lot to reduce this problem. As you may have noticed, the problem does not occur if the culling is working properly. So I created one very large mesh that filled all the empty spaces between the rooms and then let the culling do it's job. Bruteforce and time consuming, but it seems to work for me.

    Of course, if you don't like the mesh, you can always disable it on game start. It's only needed to bake the culling.
     

    Attached Files:

  9. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    594

    Actually curious about your workaround since we typically use Physically thickness in HDRP over inf walls ( like the HDRP demo requiring the shadow catcher).

    Since in your case also creating essentially an unlit shadow caster in your solution, might be worth a second pass at.

    Also i highly recommend looking through the Window> analysis> Render pipeline debugger's lighting panel and scrub through some full screen modes. This can often give hints and cleaned up views to either post and discuss or entirely hint to the issue.

    Generally though it sounded like the shadow buffer filled but alas that was already mentioned.