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

Physically Based Sky backgroundlight.

Discussion in 'High Definition Render Pipeline' started by SaphiBlue, Feb 19, 2020.

  1. SaphiBlue

    SaphiBlue

    Joined:
    Apr 18, 2016
    Posts:
    43
    Hello there,

    I just updated my project to the newest HDRP version.

    I noticed some Strange behavoir of the background lighting If I change the rotation of the Sun (day/night cycle), so the rotation in ervery frame is a little bit differnent.
    The Background-Lighting just keeps it inital value, as you can see in the Screenshot. But If I stop the rotation of the sun, the lightmap gets udated.
    • HDRP 7.2.1
    • Unity 2019.3.f1
    Does someone have a clue, what can be missing to get an updating background light on every frame? The Update Mode of the Sky is on 'Realtime'
     

    Attached Files:

    • bug.png
      bug.png
      File size:
      626.3 KB
      Views:
      479
  2. unit_dev123

    unit_dev123

    Joined:
    Feb 10, 2020
    Posts:
    989
    u baking sun or realtime?
     
  3. SaphiBlue

    SaphiBlue

    Joined:
    Apr 18, 2016
    Posts:
    43
    I have tested some cases, erverthing should be realtime. There is no baking active.
     
  4. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    Did you set the ambient mode to dynamic or static? Did you set the volume asset and physically based sky in the scene's lighting setting?
     
  5. SaphiBlue

    SaphiBlue

    Joined:
    Apr 18, 2016
    Posts:
    43
    I already tested this, nothing changes.

    Only If I disable the Updatescript for the sun rotation.
     
  6. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    That is strange but I think they made some changes due to high performence issues when updating the sun. What is the update mode for you sky? On demand, on changed or realtime?
     
  7. SaphiBlue

    SaphiBlue

    Joined:
    Apr 18, 2016
    Posts:
    43
    Its on Realtime.

    I have now this workaround

    Code (CSharp):
    1.         tick -= Time.deltaTime;
    2.         if (tick <= 0.0f)
    3.         {
    4.             tick = tickLength;
    5.      
    6.  
    7.             float timeRotation = timeOfDay * 360.0f;
    8.    
    9.             sunData.sunRotator.transform.localEulerAngles = new Vector3(0.0f, timeRotation, 0.0f);
    10.         }
    Looks a little bit flickery, but the lightmap is updating.
     
    Last edited: Feb 20, 2020
  8. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    Interesting, how did the script looked before?
     
  9. SaphiBlue

    SaphiBlue

    Joined:
    Apr 18, 2016
    Posts:
    43
    The If statment is new, as I said, the background lighting gets updated if the sun stops moving

    So if move the sun ervery 50ms

    this is the script before I changed it.

    Code (CSharp):
    1.  
    2. float timeRotation = timeOfDay * 360.0f;
    3. sunData.sunRotator.transform.localEulerAngles = new Vector3(0.0f, timeRotation, 0.0f);
    4.  
     
  10. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    It sounds like a performence optimization done by Unity since refreshing the sky is quite expensive. Some versions before, the sky was refreshing at every frame and users complained about massive cpu spikes. So I think that is the compromise.
     
  11. SaphiBlue

    SaphiBlue

    Joined:
    Apr 18, 2016
    Posts:
    43
    before updating to HDRP 7.2.1 I noticed a memory leak in the editor.

    But updating ervy frame is required to have nice and smooth transition of the sun for a day/night cycle.
     
  12. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    I think it was not developed to be updated every frame. So it preventing you from getting performence issue, therefore not updating. But the sun does not have to moved every frame. Do you need a time lapse that is so fast? If you try for example only updating it every 10th frame.
     
  13. SaphiBlue

    SaphiBlue

    Joined:
    Apr 18, 2016
    Posts:
    43
    I already tried a day/night cycle of 1 hour and sun update ervery second, but there is still a flickering effect.

    Update: I Tested this with an emtpy Project with just HDRP added. Whenever I set a ambient mode (dynamic or static does not matter, both results are the same), the Backgroundlight is not updating while the sun moves. The Skyitself is working very smoothly.
     
    Last edited: Feb 20, 2020
  14. SaphiBlue

    SaphiBlue

    Joined:
    Apr 18, 2016
    Posts:
    43
    Hello,

    sorry for double posting, but getting this working (day/night cycle) is kinda critical for my project.
    I have made a Youtube Video

    Here you see, if I set the Ambmient Mode (for the Background lighting) then the problem becomes visible.
     
    valarnur likes this.
  15. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    789

    This is probably caused by one of two things or even both.
    - Reflection probes were baked for one lighting condition and never updated so they stayed at that lighting condition.
    - Lightmaps were baked for one lighting condition and never updated so they stayed at that lighting condition.
     
  16. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    789
    Also, Dynamic Ambient Lighting mode seems to be broken, it's best to use Static mode. You will need to assign the same sky volume component in the Lighting Tab Inspector under Environment and change the sky to Physically Based Sky
     
  17. SaphiBlue

    SaphiBlue

    Joined:
    Apr 18, 2016
    Posts:
    43
    I have already did this, as you see in the Video, the background light behaves just the same.

    The Samplescene in the video does not have a Reflection Probe nor baked light.
     
  18. sk8terboy4

    sk8terboy4

    Joined:
    Mar 29, 2013
    Posts:
    29
    Any updates on this? I have the same problem
     
  19. SaphiBlue

    SaphiBlue

    Joined:
    Apr 18, 2016
    Posts:
    43
    andywatts and valarnur like this.
  20. sk8terboy4

    sk8terboy4

    Joined:
    Mar 29, 2013
    Posts:
    29
    nice. :D Thanks for letting me know