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

Shadows flickering in Scene View

Discussion in 'High Definition Render Pipeline' started by dgoyette, Jun 25, 2022.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    I'm seeing some ugly shadowing on objects in the Scene view. So far it's only the scene view, not in game. This is under 2021.3.5



    It seems to be an issue that occurs depending on how many lights are enabled. In this short clip, you can see me turning on and off big chunks of the level, which turns on/off lots of lights at once. When I disable most of the rest of the level, the shadows here look fine. But with lots of lights turned on, the shadows flicker like this.

    I'm updating from 2019.3, where this wasn't an issue. Not sure if this is a common thing I'll need to find a workaround for...
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    This is also an issue in the HDRP Demo project, and is easily reproduced by selecting any of the spotlights, and creating a dozen duplicates of it.



    I suppose this is just a matter of the engine trying to generate more shadows than it can handle. But the result is unexpectedly flickery. I thought it was just an Scene view issue, but it happens in the Game view as well, provided that occlusion culling doesn't prevent lighting from being occluded.

    So, I guess the takeaway is, don't have so many shadow casters on-screen at once? Or maybe the flickering is a bad way to handle the case of too many shadow casters? I remember under built-in, the engine would just render shadows for the nearest N lights, I think.
     
  3. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    Try Increasing maximum shadows on screen (in HDRP asset, shadow section).
    After that make sure the shadow atlas is big enough to handle your shadows, but I think increasing max shadows will fix this. (Try 256 or more)
     
  4. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    That might help if a quick fix is needed. I think I ultimately found with this that eventually, no matter how high you set those things, with enough lights you'll eventually run into this. And just increasing the total budget for lights becomes impractical at some point. So, ultimately, I wondered if the way HDRP handled going over budget on shadow casters could look better, given that it's not necessarily simple to prevent too many shadow casters at a time. Per my past post, it felt like the built-in renderer was perhaps more graceful at this, where lights were turned off. But I haven't testing this out in a while now, so I don't know if the latest version of HDRP changed this behavior at all.
     
  5. JackPotato

    JackPotato

    Joined:
    Jul 16, 2018
    Posts:
    7
    I don't suppose you ever solved this? I've run into this issue and increasing the Light Atlas resolution seems to be the only thing that helps. I've narrowed it down to the number of real-time point lights I have lighting the rooms of my building but unfortunately I can't find another way to effectively light the rooms without using some combination of light layers and other techniques.

    Currently need to bump up the resolution from 2048 to the max 16384 before the flickering stops - not very sustainable...
     
  6. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    I just opened the scene I was originally seeing this in, and I'm no longer seeing it happen. I'm not sure how to explain that, unless it's a recent change on the 2021 LTS stream.

    In any case, if this is happening, it might be something you just need to put up with. It should only be in the Scene view (not the Game view), so it's just annoying in the editor. But I think one approach to mitigating it would be to turn on Occlusion Culling in the Scene view camera settings, assuming you use occlusion in your scene. That should reduce the number of lights getting rendered, which is what this flickering is caused by. (Though, I personally don't like having Occlusion Culling enabled on the scene view camera, so that might not be a great solution.)