Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

HDRP: How to trigger shadow map calculation via script?

Discussion in 'Graphics Experimental Previews' started by Cell-i-Zenit, Mar 7, 2020.

  1. Cell-i-Zenit

    Cell-i-Zenit

    Joined:
    Mar 11, 2016
    Posts:
    181
    Hi,

    currently i have real time shadow map calculation activated, but i only need the "updating" in a really specific time frame so i would like to trigger it myself (choosing "On Demand" in settings).

    But i cannot find how i can trigger it.

    Can you help me?
     
  2. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    455
  3. Cell-i-Zenit

    Cell-i-Zenit

    Joined:
    Mar 11, 2016
    Posts:
    181
    Thanks this helped @alexandre-fiset

    But there is something off. If i enable the realtime shadows everything looks as expected and the shadows look like they should.

    But if i stop doing this and choosing the ondemand version, the shadows only look good when i trigger the shadow generation "manually" each frame. The moment i stop triggering it, it starts to look bad and "random blobs of shadow" appear on the ground. I also noticed that all other shadows are disappearing.

    Is this triggering only happening for this single frame? If yes, is there a way to "remember" the latest shadow map somehow?


    Here a picture how it looks like WITHOUT triggering the shadow map generation each frame
    https://imgur.com/a/titI1i5
     
  4. fairchild670

    fairchild670

    Joined:
    Dec 3, 2012
    Posts:
    63
    Not sure if you've figured this out already, but apparently OnDemand shadow maps are generated according to the camera frustum at the time of the request. At least this is the behavior I've noticed while changing the camera view and calling the HDAdditionalLightData.RequestShadowMapRendering() function.

    There is a thread out there where this is sort of documented, but I can't seem to find it just yet.
     
unityunity