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

ShadowMap OnDemand update does not create a full map

Discussion in 'High Definition Render Pipeline' started by AudrasC, Apr 15, 2020.

  1. AudrasC

    AudrasC

    Joined:
    Feb 19, 2016
    Posts:
    19
    Hello,

    In my project, I am loading scenes from Assetbundles and when everything is loaded, call the function RequestShadowMapRendering on the light having ShadowMap enabled. Only the directional light has shadowMap setting on OnDemand.

    In the image below we can see that the shadowmap stops clearly.
    shadowMap.jpg

    Does anyone knows how to resolve this problem ?

    Using:
    - Unity 2019.3.4
    - HDRP 7.2.1

    I have tried to increase Max Shadow Resolution in the HDRP profile and to decrease the Shadow Precision.
    I tried to do the RequestShadowMapRendering 1 second to 5 seconds after all scenes have been loaded but the problem remains.

    Edit: I now update the sadow map manually (when pressing a key) and I notice that behind the camera the shadow map is not created which makes a seperation like in the Screenshot.

    Edit2: I made a default HDRP project and set the shadowmap on OnDemand. When I request update of the shadow map, the objects behind the camera do not get shadow. How to tell unity that I want to create shadow for all objects on the scene.
     
    Last edited: Apr 16, 2020
  2. AudrasC

    AudrasC

    Joined:
    Feb 19, 2016
    Posts:
    19
    I bump this.
    Right now, we are using [Every Frame] shadowmap and it is quite heavy so we would like to move to [OnDemand].
    Does anyone was able to make [OnDemand] shadowmap working correctly ? Can you share your parameter ?

    The main problem is that the shadowmap is not created for object behind the camera (even a few meters behind). So when I rotate the camera, we can easily see that objects don't have shadow.
    I tried by creating a default HDRP project and set the shadowmap on [OnDemand] but with no success.
    Thank you.
     
  3. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    635
    This is totally expected for a directional shadowmap, as the rendered shadowmap depend on the frustum of the camera.
    If you want something that covers all your scene, independently of the camera point of view, you could :
    • Use an other kind of light, like a spot light set as "box" to have parallel light rays
    • Move the camera in a way that it sees all the scene, render the shadowmap for the directional, and move back the camera to your point of view (this might still cause rendering issues due to cascades ...)
     
    DrSeltsam likes this.
  4. AudrasC

    AudrasC

    Joined:
    Feb 19, 2016
    Posts:
    19
    Thank you Remy for your response.

    In our case, I think we can use the first option you proposed.
     
  5. AudrasC

    AudrasC

    Joined:
    Feb 19, 2016
    Posts:
    19
    @Remy_Unity

    I tried the first option and even when using a spotlight, the same thing happen when setting the shadowMap to OnDemand. Objects behind the camera don't cast shadows.
    I don't know what parameters need to be changed to make it work.

    Using Unity 2019.3.4f1 and hdrp 7.1.8
     
  6. uMotiejus

    uMotiejus

    Unity Technologies

    Joined:
    May 13, 2019
    Posts:
    12
    Hello AudrasC,

    This is a known issue. I'm currently testing a new implementation that would solve your case. However, its no small fix requiring a refactor, I'm not sure when it will be released, for tracking you could submit a bug and you would get notified when the fix version is released.
     
  7. AudrasC

    AudrasC

    Joined:
    Feb 19, 2016
    Posts:
    19
    Thank you for your response.

    We'll wait until the patch arrive.
     
  8. sgthale

    sgthale

    Joined:
    Mar 10, 2018
    Posts:
    11
    FYI it actually does work as intended however if you have a random unused camera floating around in your map then the shadows will be rendered from THAT point, causing the strange black background artefacts on the main camera. Flagging cameras as main had no effect. Just make sure you only have 1 camera active at all points.

    I am rendering shadows for a VR game every 4 frames with great results. However I need to make sure only 1 camera is active/enabled at any point otherwise the shadow bug comes back. Unintuitive for sure and the behavior borders glitchyness but it's totally workable.
     
    uMotiejus likes this.