Search Unity

Dynamic day and night cycle with Global Illumination and reflection probes

Discussion in 'General Graphics' started by alexandre-fiset, May 24, 2019.

  1. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    715
    Hi!

    We are trying to find the best method to have a dynamic day and night cycle system.

    Here are some the potential solutions we found, and their associated limitations:

    1. Reflection Probes set to Realtime and Render each frame

    This is the most visually accurate solution, but also the more costly.

    upload_2019-5-24_10-40-5.png

    Problems
    • Timeslicing does not work, which means the probe renders its 6 faces each frame.
    • In HDRP, the minimum resolution we can have for our probes is 128, which means rendering 6 times that, 98 304 pixels each frame with shadows and ect. With a resolution of 16, this would have been much more acceptable, but custom resolutions for probes are not supported in HDRP.
    • At ~12 ms per frame on a i5 in the default HDRP sample scene, this is way too costly
    2. Rendering probes at specific time

    By switching its Realtime Mode to OnDemand, we can choose the moment where we update our probes. We could, for instance, render the probe when the player opens a door.

    Problems
    • It still can take dozens of miliseconds to render a single 128 px probe, so that stutter will be visible to the player.
    • Having two or three probes in a room will result in reflections not looking smooth as the sun moves. For that, we could stop time in interior scenes, which is not really that bad, but still not 100% ideal.

    3. Rendering a cubemap from another camera to use as a custom probe

    This is a bit faster than real time probes, and we could ultimately timeslice its baking at one face per frame instead of all six.

    upload_2019-5-24_10-39-29.png

    Problems
    • As of Unity 2019.1 and as shown above, the resulting cubemap renders all black on reflective surface. So it does not seem to be supported. I submitted a bug, but anyway it is still pretty intensive on the CPU.
    • The rendered cubemap does not look the same / as accurate as reflection probes.
    4. Array of baked HDRI cubemaps + ReflectionProbe.BlendCubemap

    We could split our day in 12 distinct steps and blend between the past cubemap and the incoming one in order to fake the transition.

    Problems
    • As of Unity 2019.1, the resulting cubemap is baked in HDR format, but not baked with HDR values for each pixel. In a high-LUX scene, this again causes reflective surfaces to render all black.
    • This takes a substantial amount of memory.
    • Async loading of a cubemap creates a stutter similar to baking it in realtime.

    Has anyone ever achieved something similar? Any trick we should be aware of?

    Cheers!
     
    mgear, keeponshading and drewhong like this.
  2. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    715
    Bumping as this is still an issue, even more considering the recent announcement of Enlighten deprecation.
     
  3. alsharefeeee

    alsharefeeee

    Joined:
    Jul 6, 2013
    Posts:
    80
    You can bake a reflection prop every few minutes and to prevent any stutter you could bake them one by one every few seconds.

    I am trying to do a day night system myself and this what I thought of.
    Hope this helps!
     
  4. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    I'm looking forward to rtx.
     
  5. sarahlasley

    sarahlasley

    Joined:
    Oct 25, 2018
    Posts:
    2
    Looping back to see if anyone has found a solid solution for changing the HDRI Sky cubemap for day-night cycle in HDRP?
     
  6. naelstrof

    naelstrof

    Joined:
    Sep 12, 2017
    Posts:
    22
    With the HDRender pipeline being out of preview, it'd be nice if this was addressed.

    Rendering a single probe takes over 60ms, pretty much unfeasible to hide that kind of jitter. Any kind of time slicing or being able to cut the resolution would be wonderful!
     
  7. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,644
    Is this still a problem? Apparently real-time probes are still unusable in HDRP and the TimeSlice option doesn't even exist
     
    Last edited: Aug 26, 2021
  8. reddotgames

    reddotgames

    Joined:
    Apr 5, 2011
    Posts:
    707
    How did you managed to handle all that?