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 On demand shadow maps on per object basis

Discussion in 'High Definition Render Pipeline' started by Sooly, May 16, 2023.

  1. Sooly

    Sooly

    Joined:
    Jan 28, 2021
    Posts:
    15
    I got a day-night cycle system that moves directional light according to time. As an optimization I want to use OnDemand Shadow Map update - either with update on light movement or by manualy invoking every nth frame.
    The issue is, when actors move across the scene, their shadows follow them with a visible lag. Is it possible to use on demand update for static objects only and keep full realtime for dynamic ones?
    Only thing that comes to my mind is to use two separate lights and light layers but maybe there is a better solution out there.
     
  2. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    629
    HDRP doesn't support for mixed cached shadowmaps on directional lights, that would be the best solution...
    However, you could mitigate the issue you have by having only the closest shadowmap slice to update every frame, and update the others in a time sliced fashion.
     
  3. Sooly

    Sooly

    Joined:
    Jan 28, 2021
    Posts:
    15
    I forgot to mention that it's a top-down, RTS-like view, so that might not be possible. On the other hand, things that happen in screen corners might not be that visible, I guess. I will look into that, thanks!
    Eventually I will light only dynamic stuff with the directional light and create a spot light with on demand shadow map for the rest, maybe that will do. But I got a feeling that keeping a consistent look between them will be a pain. :)
     
  4. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    629
    In that case, do you "really" need directional light with shadow cascades ?
    Maybe you could replace your light by a box light with mixed cached shadows, that follows the camera to cover the screen ?
     
  5. Sooly

    Sooly

    Joined:
    Jan 28, 2021
    Posts:
    15
    Sounds good, will try it. Not sure if it is feasible at this point in development, we are quite close to the release. This system is not my creation and we got a lot of interlaced things there, so I am extra careful.
    Just need a little bit more performance on consoles.
    Thanks for the suggestions.
     
  6. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    734
    Was mixed cached shadows for directional lights not introduced with 2022.1?
     
  7. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    629
    Sooly likes this.
  8. rohanvw

    rohanvw

    Joined:
    Feb 22, 2023
    Posts:
    1
    I am facing a similar issue with circular shadows which moves with camera.
    Using OnDemand and updating the render every 0.5 seconds.
    Tested with Unity 2020.3.30f1 and 2022.3.0f1.
    I don't see the option - Allow Mixed Cached Shadows in 2020.3.30f1 here is the screenshot
    upload_2023-8-22_11-34-32.png

    The option is available in 2022.3.0f1 but even after enabling it the shadow is still visible.

    The issue : Circular shadow appears around the camera.
    upload_2023-8-22_11-40-12.png
     
    Sooly likes this.