Search Unity

  1. 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
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Time of Day - Dynamic Sky Dome

Discussion in 'Assets and Asset Store' started by andererandre, Mar 4, 2013.

  1. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,028
    Thanks, I just wanted to make sure before I adjusted stuff that it wasn't a setting I missed.

    Thanks I've removed the default light a long time ago. :)
     
  2. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,028
    Should the cloud cover affect the sun brightness and shadow intensity? When i use the weather presets, the sky is overcast but the sun and shadows don't match. See below:

    Carp Fish Sim - Screenshot 00064.png
     
  3. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    680
    Up until now cloud shadows were supposed to be used to darken the world with overcast skies, but since not everybody wants or can use them I plan to extend the weather manager to directly adjust the light source intensity as well in the next release.
     
  4. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,028
    That sounds perfect. Never had great results with the cloud shadows, got strange results.
     
  5. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    680
    PSA: Version 2.3.1 introduced a bug with the change "Added headless mode detection to skip some rendering calculations when running on a server", the code of which is in TOD_Sky+Settings.cs:

    Code (CSharp):
    1. if (SystemInfo.graphicsDeviceID == 0) return;
    It looks like graphicsDeviceID is zero on a lot (all?) mobile devices as well, which causes the sky dome to render completely black on iOS and Android as Time of Day switches to its headless server mode. The simple fix is to remove all three occurances of this line in TOD_Sky+Settings.cs until 2.3.2 has been reviewed by the Asset Store team.

    Sorry for any inconveniences this bug may have caused.
     
  6. Xaron

    Xaron

    Joined:
    Nov 15, 2012
    Posts:
    264
    Looks fantastic! Can this be mixed with weather systems like Liquidum Pro?

    edit: oh well just saw that there is the ARS weather system. :)
     
    Last edited: Nov 24, 2014
  7. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    680
    Time of Day should be very agnostic with regards to weather particle systems. ARS is integrated quite nicely out of the box, but any other particle effects should be just as easy to integrate with the example scripts I provide.
     
  8. unicat

    unicat

    Joined:
    Apr 8, 2012
    Posts:
    416
    Got an error after importing ToD in U5 beta 14:

    Assets/Time of Day/Assets/Scripts/TOD_Sky+API.cs(447,18): error CS0246: The type or namespace name `SphericalHarmonics3' could not be found. Are you missing a using directive or an assembly reference?

    Worked fine in U5 beta 13.
     
    Last edited: Nov 24, 2014
  9. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    680
    SphericalHarmonics3 was renamed to SphericalHarmonicsL2 in beta 14. Time of Day will be updated to beta 14 in 2.3.2, but it's still in review by the Asset Store team. If you send me an email with your invoice # I can send you a download link.
     
  10. unicat

    unicat

    Joined:
    Apr 8, 2012
    Posts:
    416
    Ah, ok . I am waiting for the asset store update then. I am only testing U5.
    Thank you.
     
  11. evilt0m

    evilt0m

    Joined:
    Jun 8, 2013
    Posts:
    7
    Can you estimate how long the review will take?
    I'm curious if this update fixes my GI objects too bright at night issue.
     
  12. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    680
    2.3.2 is out!

    Are you using Enlighten? If so, its global illumination of course has to be refreshed when the time of day changes. I haven't used Enlighten much so I can't really talk you through it, but there was some talk about it being able to deal with dynamic day / night cycles, so I would assume it's capable of handling this.

    I would also like to note that some of the info on Unity 5 reflection probes I posted a few weeks ago is outdated as of Unity 5 beta 14. Reflection probes can now also refresh at runtime. Doing so is still an expensive operation, but it might make sense for some projects. For more info on this and details on how I suggest using the Unity 5 ambient light and reflection features with Time of Day check out the Time of Day docs: http://modmonkeys.net/dat/doc/timeofday/#ambient
     
  13. evilt0m

    evilt0m

    Joined:
    Jun 8, 2013
    Posts:
    7
    Yes, I use Enlighten. And it works just fine if I use the gradient ambient mode. But if I use the spherical mode, the static GI meshes aren't affected by the ambient color.
     
  14. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    680
    I'll have to check and see why that is the case. I'll try to fit it in this weekend.
     
  15. Demonith88

    Demonith88

    Joined:
    Jun 30, 2014
    Posts:
    215
    Its too much blight can i lower the light somehow
     
  16. AchillesPDX

    AchillesPDX

    Joined:
    Aug 21, 2014
    Posts:
    1
    If anyone's interested, I updated the GUI with the new variable names, hopefully this helps someone.

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class SkyTestGUI : MonoBehaviour
    4. {
    5.     public TOD_Sky sky;
    6.     public bool fog, sunShafts, progressTime;
    7.    
    8.     private Rect rect = new Rect(-3, -3, 200, 450+6);
    9.     private const float label_width = 100;
    10.    
    11.     private string[] cloudTypes = {
    12.         TOD_CloudType.None.ToString(),
    13.         TOD_CloudType.Few.ToString(),
    14.         TOD_CloudType.Scattered.ToString(),
    15.         TOD_CloudType.Broken.ToString(),
    16.         TOD_CloudType.Overcast.ToString()
    17.     };
    18.    
    19.     private string[] weatherTypes = {
    20.         TOD_WeatherType.Clear.ToString(),
    21.         TOD_WeatherType.Storm.ToString(),
    22.         TOD_WeatherType.Dust.ToString(),
    23.         TOD_WeatherType.Fog.ToString()
    24.     };
    25.    
    26.     protected void OnEnable()
    27.     {
    28.         if (!sky) sky = TOD_Sky.Instance;
    29.     }
    30.    
    31.     protected void OnGUI()
    32.     {
    33.         GUILayout.BeginArea(rect, "", "Box");
    34.         GUILayout.BeginVertical();
    35.         GUILayout.FlexibleSpace();
    36.        
    37.         GUILayout.BeginHorizontal();
    38.         GUILayout.Label("Time of Day", GUILayout.Width(label_width));
    39.         sky.Cycle.Hour = GUILayout.HorizontalSlider(sky.Cycle.Hour, 0, 24);
    40.         GUILayout.EndHorizontal();
    41.        
    42.         GUILayout.BeginHorizontal();
    43.         GUILayout.Label("Moon Phase", GUILayout.Width(label_width));
    44.         sky.Moon.Phase = GUILayout.HorizontalSlider(sky.Moon.Phase, -1, 1);
    45.         GUILayout.EndHorizontal();
    46.        
    47.         GUILayout.BeginHorizontal();
    48.         GUILayout.Label("Sky Contrast", GUILayout.Width(label_width));
    49.         sky.Atmosphere.Contrast = GUILayout.HorizontalSlider(sky.Atmosphere.Contrast, 0.5f, 1.5f);
    50.         GUILayout.EndHorizontal();
    51.        
    52.         GUILayout.FlexibleSpace();
    53.        
    54.         if (progressTime)
    55.         {
    56.             GUILayout.BeginHorizontal();
    57.             sky.Components.Time.enabled = GUILayout.Toggle(sky.Components.Time.enabled, " Progress Time");
    58.             GUILayout.EndHorizontal();
    59.         }
    60.        
    61.         if (sunShafts)
    62.         {
    63.             GUILayout.BeginHorizontal();
    64.             var shafts = GetComponent<TOD_Rays>();
    65.             shafts.enabled = GUILayout.Toggle(shafts.enabled, " Sun Shafts");
    66.             GUILayout.EndHorizontal();
    67.         }
    68.        
    69.         if (fog)
    70.         {
    71.             GUILayout.BeginHorizontal();
    72.             RenderSettings.fog = GUILayout.Toggle(RenderSettings.fog, " Enable Fog");
    73.             GUILayout.EndHorizontal();
    74.         }
    75.        
    76.         GUILayout.FlexibleSpace();
    77.        
    78.         GUILayout.BeginHorizontal();
    79.         GUILayout.FlexibleSpace();
    80.         GUILayout.Label("CLOUDS");
    81.         GUILayout.FlexibleSpace();
    82.         GUILayout.EndHorizontal();
    83.        
    84.         int cloudType = GUILayout.SelectionGrid((int)sky.Components.Weather.Clouds - 1, cloudTypes, 1) + 1;
    85.         sky.Components.Weather.Clouds = (TOD_CloudType)cloudType;
    86.        
    87.         GUILayout.FlexibleSpace();
    88.        
    89.         GUILayout.BeginHorizontal();
    90.         GUILayout.FlexibleSpace();
    91.         GUILayout.Label("WEATHER");
    92.         GUILayout.FlexibleSpace();
    93.         GUILayout.EndHorizontal();
    94.        
    95.         int weatherType = GUILayout.SelectionGrid((int)sky.Components.Weather.Weather - 1, weatherTypes, 1) + 1;
    96.         sky.Components.Weather.Weather = (TOD_WeatherType)weatherType;
    97.        
    98.         GUILayout.FlexibleSpace();
    99.         GUILayout.EndVertical();
    100.         GUILayout.EndArea();
    101.     }
    102. }
     
    novion4 likes this.
  17. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    680
    Are you on Unity 5? If so, first of all, check that you deleted the directional light that's part of the scenes now by default.

    Once you made sure there's only Time of Day lighting your scene you can adjust Sun.LightIntensity, Moon.LightIntensity, Day.AmbientMultiplier and Night.AmbientMultiplier, which adjust the directional and ambient light at day or night respectively.
     
    Demonith88 likes this.
  18. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    680
    This problem should be fixed in Unity 5 Beta 15. Can you confirm that everything works as it should now?
     
  19. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,168
    I have a problem with TimeOfDay when its Ambientmode is set to "Spherical".
    Then the Cubemap from the Skybox is passed to the Environment lighting Ambient Source.
    But that cubemap is totally uncoupled with the TOD-Sky.

    So, as a solution, we need the possibility to pass the already available realtime reflection cubemap to the
    skyboxmaterial - right?

     
  20. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    680
    This should be fine. The "skybox" and "sun" fields are unused in that scenario since the ambient probe is directly set in code. You can completely remove the skybox and sun references (i.e. set them to none) and everything will look exactly the same. I actually might automatically do this via code in a future release in case I don't decide to plug Time of Day directly into that material field - depends on which one will be the cleaner solution going forward.

    Please note that I'm talking about Unity 5b15. In Unity 5b14 there was a bug that global illumination wouldn't use the ambient probe even though it was set by Time of Day and instead fell back to the skybox material, which of course looked extremely off at night.
     
  21. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,168
    Sorry, I can´t confirm this. I´m also using b15 and setting Skybox or Sun to "None" dramatically changes the lighting.

    Setting TODs Ambient to Color works fine for Ambient Source.
    Setting TODs Ambient to Gradient works fine for Ambient Source..
    Setting TODs Ambient to Spherical uses skybox materials cubemap for Ambient Source.

    It´s just still like you said in b14.
     
    Last edited: Dec 3, 2014
  22. xandeck

    xandeck

    Joined:
    Apr 2, 2009
    Posts:
    563
    It is amazing how this system evolved and still has support. We are using for our games here (one already launched on Steam and one in production).... I just miss one thing: rain support without using alternatives methods =)
    Good work.
    EDIT: Unity5 working without problems also
     
  23. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    680
    Just tested it again and could in fact reproduce on b15 as well. I must have forgotten to set my test cube meshes to static in my last test and incorrectly assumed the issue was fixed in b15.

    I'm submitting a bug report with Unity to check in how far this behavior is intentional. At first glance it looks like a bug to me as GI completely ignores the spherical harmonics ambient probe that is set via code. For the case that the skybox material is set to "none" any changes made to the fallback "Ambient Color" field are also ignored. I was able to get the custom ambient probe to be taken into account if I unchecked "Continuous Baking" and manually hit the bake button, which makes me think continuous baking simply doesn't recognize the change.

    I'll keep you guys updated.
     
  24. Demonith88

    Demonith88

    Joined:
    Jun 30, 2014
    Posts:
    215
    Can we put some rain and thunder and how ? if i may ask
     
  25. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,168
    Thanks! For me your system is the best one available for architecture scenes, even without rain and thunder.
    I promote it as a nice solution wherever I can. Keep on working on it!
     
  26. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    680
    That's not part of the package out of the box. However, there are multiple weather effect packages on the Asset Store that all work together with Time of Day. There are some example scripts for how to integrate particle effects or sounds with Time of Day in the "Examples" folder.
     
  27. evilt0m

    evilt0m

    Joined:
    Jun 8, 2013
    Posts:
    7
    Nope, problem still exists. Static objects are really bright at night when using spherical ambient mode (if you switch to that mode during day in the editor). If you switch to spherical during night, they're too dark on day.
     
  28. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    425
    I can't seem to get the Time Curve to work. When i set the curve to extend day time or any other time it still remains in its default daylight nighttime cycle.. I have turn on Use Time Curve and adjust the Time Curve with no luck. Any ideas what could be the issue. Can someone test this feature make sure its working. I'm using the latest version of Time Of Day. I have debugged into TOD_Time script and the Evaluate on the time curve gets called but the evaluation is being done on linear 0 0 24 24. This should not be the case when i have changed the time curve. Strange.
     
  29. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    680
    Yes, you're experiencing the same issue Cascho01 and I were talking about above. I'm waiting for freedback from Unity support on whether or not this is working as intented.

    I assume you're misunderstanding how to setup the time curve. I just tested this curve, which correctly speeds up nighttime and slows down daytime:

    Screen Shot 2014-12-05 at 10.59.14.png

    The minimum point of the curve always has to be at 0/0, the maximum at 24/24 - the curve between those two points can be flattened to speed up the night and lengthen the day. If you have ideas on how to make this more user-friendly I would love to hear them.
     
  30. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    425

    I really don't know how you manage this ! No matter what shape i make the curve the cycle is the same. On my screen 18:25 the moon start to show above the horizon. Whatever curve i put in does not change this. I do have the Use Time Curve ticked! This was occuring on the last version and the latest version. Im totally stumped !

    I really want the moon to start going above the horizon around 20:30 in the evening, but its starts around 18:00. How to make this happen?

    When making changes to the curve editor is there a way to ensure the times are clamped to 0 0 24 24? Manually adjusting the curve is hard to get it exactly on 24?
     
    Last edited: Dec 5, 2014
  31. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    680
    The time you set on the prefab doesn't change with the time curve. If you set the prefab to 18:25 then the moon will always be at the exact position it's supposed to be at 18:25. That means the lighting conditions at 18:25 will fit the lighting in real life.

    However, once you hit play time progresses at a speed that is determined by the time curve set in TOD_Time. Let's assume nighttime takes 12 hours and daytime takes 12 hours. No matter what time curve you set, nothing will change those numbers. However, those 12 ingame hours at night might progress in 1 real-life minute and those 12 ingame hours at day might progress in 9 real-life minutes, depending on what your time curve looks like.

    The reason it works like this is that you'll be able to use Cycle.Hour the same way you would check your watch in real-life. The time curve does not screw with the position of the watch hand, but it does affect how fast the watch hand moves at a specific point in time.
     
  32. joeconstable97

    joeconstable97

    Joined:
    Jul 30, 2013
    Posts:
    32
    Hi, I've recently been looking into the moon phases and was wondering whether there was a way to have this tool automatically set up the phase depending on the position of the moon corresponding to the sun.
     
  33. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,168
    Any news on that?

    You could improve your plugin concerning the moon:
    The area around the moon is missing stars, even when halo is disabled/black.
    Add a halo size parameter.
     
  34. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    680
    This is not possible at the moment, but you can set the moon position to realistic, set the moon phase to something that makes sense for that date and have it go through the monthly cycle from there. This will approximately be correct, though it will diverge after a few months of ingame time.

    I'm in the process of talking to some devs about this. The current state of things is that GI is "working as intended" by ignoring the ambient probe during the baking process, but we're not done talking just yet. Should things stay as they are I'll have to look for a workaround, which will probably be to provide a custom material to assign to the skybox field. That being said, there still seem to be a couple of bugs in the whole lighting setup, so I can't give an ETA for the fix at this point. I'm sure it'll be before Unity 5 leaves beta though.

    Did you have the stars set to rotating by any chance? If so there probably just aren't any stars around the moon in the night sky texture for the tiling value you're using. I just tested it and the halo definitely doesn't block any stars if set to solid black.

    Fair enough, I'll note it down.
     
  35. joeconstable97

    joeconstable97

    Joined:
    Jul 30, 2013
    Posts:
    32
    Alright, thanks for replying :)
     
  36. cjrussel14

    cjrussel14

    Joined:
    Jun 20, 2014
    Posts:
    69
    how to add real time shadows.. do i still need to add directional light?

    and my game is not a sandbox,it is scene by scene
    how to set the skydome prefab and run the time,day,month globally
     

    Attached Files:

    Last edited: Dec 10, 2014
  37. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    680
    @evilt0m @Cascho01 I experimented a bit further decided that I will submit a fix for dynamic GI this weekend that should allow you to use GI and still have realtime reflection cubemaps. However, keep in mind that there are still bugs in dynamic GI that might break it in your projects. At least this way Time of Day is prepared in case things will stay the way they are.

    The directional light is part of the "Sky Dome" prefab, it's called "Light" and has all the parameters any other directional light has. You can adjust shadow casting parameters directly on there.

    You simply track the variables in TOD_Sky.Instance.Cycle in static variables in a custom script. Another way that might work is calling DontDestroyOnLoad on the sky dome and only adding it a single time on game start.
     
    evilt0m and Cascho01 like this.
  38. cjrussel14

    cjrussel14

    Joined:
    Jun 20, 2014
    Posts:
    69
    i tweak it but i don't receive any shadows..here is my setting Untitled.png
     
  39. alex-rudenkiy

    alex-rudenkiy

    Joined:
    Mar 15, 2014
    Posts:
    1
    Got an error after importing ToD in U5 beta 14:

    Assets/Time of Day/Assets/Scripts/TOD_Sky+API.cs(447,18): error CS0246: The type or namespace name `SphericalHarmonics3' could not be found. Are you missing a using directive or an assembly reference?

    Worked fine in U5 beta 13.
     
  40. cjrussel14

    cjrussel14

    Joined:
    Jun 20, 2014
    Posts:
    69

    how do i track those variables? sorry for such question.. i'm entirely new to scripting.
     
  41. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    680
    I was talking about the "Light" game object. Click the arrow left to the "Sky Dome" game object in your project hierarchy. Also, don't set your sun shadow strength to 0 on the TOD_Sky script if you want to use shadows.

    Update Time of Day to version 2.3.2. Beta 14 changed the name of spherical harmonics.

    Please understand that this thread is not the right place to discuss beginner scripting.
     
  42. cjrussel14

    cjrussel14

    Joined:
    Jun 20, 2014
    Posts:
    69
    hmm.. i set the graphical emulation to "no emulation" and it worked,, i wonder why the shadow doesnt show in open gl 2.0
     
  43. cjrussel14

    cjrussel14

    Joined:
    Jun 20, 2014
    Posts:
    69
    ok i understand..sorry,,hve one question though.. i have following this tutorial 'calling function from other scripts''
    is that what u mean?
     
  44. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    425
    When increasing the haziness i'm getting black light pods surrounding the horizon line of the sky dome. Any idea what would be causing this issue and a fix for it?
     
  45. Zerseu

    Zerseu

    Joined:
    Feb 3, 2014
    Posts:
    10
  46. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    680
    Sorry for the late reply - the forum software didn't notify me about any of the new posts in here.

    The light source is a standard Unity light source, so you'll probably have to investigate this in the official docs.

    Hard to tell from the title alone. Any Unity scripting tutorial should discuss this sort of thing though.

    What's your platform? Are you using DX11? Is it happening in an empty scene with just the sky dome in it?

    I'll have to look into this and get back to you. It looks to me like a ~90 degree offset of some sort. Thanks for reporting!
     
  47. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    680
    2.3.3 is out! This means that dynamic GI is now supported. Since GI is fairly buggy on b14 I recommend upgrading to b17 if you plan on using it.

    Are you still interested in this? I'm working on some moon changes to support eclipses and stuff like that and I was thinking maybe I should calculate the correct moon phase while I'm at it.
     
    hopeful likes this.
  48. Sendatsu_Yoshimitsu

    Sendatsu_Yoshimitsu

    Joined:
    May 19, 2014
    Posts:
    674
    I just updated to the newest TOD, and I'm getting two identical warnings on my main camera, "Using skybox camera clear flags in a scene with a sky dome is redundant". Is there any chance you can give me an idea of where I should be looking to fix this? I don't see any problems in-game, but warnings make me paranoid. :)
     
  49. Zerseu

    Zerseu

    Joined:
    Feb 3, 2014
    Posts:
    10
    Click the camera object in the hierarchy and in the inspector set clear flags to solid color (I use transparent black for my scene). Hope this helps.
     
  50. Sendatsu_Yoshimitsu

    Sendatsu_Yoshimitsu

    Joined:
    May 19, 2014
    Posts:
    674
    Oh, that worked! Thank you very much :)
     
unityunity