Search Unity

Time of Day - Dynamic Sky Dome

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

  1. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    At this point you might be best off rendering the sky dome together with the mountains in their own camera before rendering the rest of the scene. Another thing to consider is that the far clip plane actually has very little effect on the depth buffer accuracy - way less than the near clip plane - so you could also increase your far clip plane to solve this.
     
  2. sgoodrow

    sgoodrow

    Joined:
    Sep 28, 2012
    Posts:
    150
    Very interesting, I did not know that. I will experiment with both of your suggestions, thank you again for your help!
     
  3. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    Unity 5 is gonna be nice:

    Screen Shot 2014-08-28 at 23.57.28.png

    Tricolor / hemisphere ambient light + fully dynamic reflection cubemap of the sky. Both the ambient light and the cubemap are automatically created by TOD in less than 0.2ms.
     
    nasos_333, derkoi, hopeful and 2 others like this.
  4. ERCentertainment

    ERCentertainment

    Joined:
    Jun 17, 2013
    Posts:
    17
    Sky coloring value doesn't do anything for me since I updated. Is it supposed to be that way?
     
  5. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    No it's not supposed to work that way. Looks like it uses Light.Coloring instead of Light.SkyColoring together with the light source by accident. You can adjust Light.Coloring instead as a workaround.

    I'll include the fix in 2.1.2, which should be ready for submission this weekend - if you need it ahead of time contact me with your invoice # and I'll send you the latest internal build.
     
  6. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    I added full support for ambient light based on spherical harmonics for Unity 5 today. Due to this I had to add quite a few new parameters and decided to add separate parameter sections for fog, ambient light and reflections, most of which were previously part of the world parameter section.

    Since this can break compilation in existing projects (i.e. TOD_Sky.World.SetFogColor is now the TOD_Sky.Fog.Mode enum and various other changes like that) I decided to relabel 2.1.2 as 2.2.0 to make clear that it's more than a fix release with minor additions.
     
  7. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Hi, unlikely I still don't have access to unity 5. I wonder why some developers already have it. I bought the upgrade long time ago already. Do you know more about the procedure, or Unity will send a persoal email?

    Anyway how it will work ToD with Unity 5? I saw in some video that from the skybox Unity calculate the ambient light. With ToD was not needed to use skybox anymore. So also in Unity 5 is there a way to influence the image based ambient light without using a skybox?

    Thanks
     
  8. OnePxl

    OnePxl

    Joined:
    Aug 6, 2012
    Posts:
    307
    It's in closed beta now. It's clear that asset store developers are in on that. The beta for pre-orders was announced at Unite 2014 to arrive in two months time*.

    * Unity time, not actual time probably ;D
     
  9. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    There are now 4 out-of-the-box ambient settings + a custom ambient probe mode:
    • Flat (same as in Unity 4)
    • Hemisphere (ground + sky color)
    • Trilight (ground + equator + sky colors)
    • Skybox (baked 3rd order spherical harmonics from a static skybox)
    • Custom ambient probe (any 3rd order spherical harmonics, need to be calculated via code)
    TOD will support all of those modes, though the static skybox bake doesn't make too much sense if the dynamic day / night cycle is enabled. There are also 2 reflection modes:
    • Skybox (baked cubemap from a static skybox)
    • Custom (any cubemap set via custom code, can be static or dynamic)
    Plus reflection probes that can be scattered around the level to have special reflections for certain areas. As I understand it reflection probes can be static and dynamic, though dynamic reflection probes will probably be fairly expensive and not feasible for vast open areas with a dynamic day / night cycle. This is why I added a feature to TOD to bake a skybox-only reflection cubemap that can be generated extremely quickly and is easy to update as the day / night cycle progresses.
     
  10. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    @OnePxl Yes I was supposing that. So maybe I should publish some nice free script on the asset store :p
    @plzdiekthxbye Thank you for the detail explanation. Very interesting indeed.
    Could be useful also to generate a reflection cubemap including some geometry of the environment, so to have some trees and terrain reflected. The problem is that in the sample picture above the reflection on the bottom of the spheres is blue (I suppose that is the bottom of the skydome) while the ground is white and doesn't look very nice.
     
  11. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    Actually TOD will let you specify a color to fade to in the bottom half, which should be a dark blue or brown for most scenes.
     
  12. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Yes that will help for sure :)
     
  13. Morfeuskiev

    Morfeuskiev

    Joined:
    Oct 10, 2013
    Posts:
    122
    Hello. Thank you for your high quality work. Time of Day work is very fast. So i have a two question:
    1) Your weather has a beautify atmosphere effect. But Cloud layer is very simple. Are you planning to improve the cloud system?
    2) Can I create multiple layers of the cloud with different texture? Sorry about question. I see the documentation and did not find this opportunities.
     
  14. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    Yes, clouds will be improved with the 2.3.0 update. It was planned for 2.2.0 but this became the Unity 5 compatibility update instead.

    It's possible, but you'd have to manually set the cloud layer parameters on all of those materials duplicates, so I wouldn't recommend doing it.
     
  15. Morfeuskiev

    Morfeuskiev

    Joined:
    Oct 10, 2013
    Posts:
    122
    plzdiekthxbye

    Very thanks for the quick reply. Question-Proposal:
    Why not change the source of the Sunshaft effect from the sun to the moon, when the nighttime falls? The contrast between the brightness of the source (the moon) and the light(Shadows is more darkness) is more than in daytime. Accordingly, the effect of the sunshaft rays more visible. That would be spectacular.

    With Best Regards, Leonid.

    update:

    Could be added to the setting rays for three positions:
    1) Day
    2) Sunrise / Sunset
    3) Night

    And smooth change depending on the time of day.
     
  16. Lupin500

    Lupin500

    Joined:
    Mar 6, 2012
    Posts:
    25
    Hello plzdiekthxbye,

    I'm currently using TOD for a multiplayer project and it's great! But I have a question regarding synchronizing cycle settings for multiple clients. I read in the documentation that TOD_Sky.Cycle.Ticks is the property to synchronize but I'm not sure how to do that with networkView.RPC. Ticks is long but RPC doesn't support that. I'd love to hear some input from you on how to properly do that. Thanks!
     
    Last edited: Sep 3, 2014
  17. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    I'll look into this.

    While you could theoretically also sync hour, day and year individually I would recommend using the "Ticks" property and send it as a byte array. Google should spit out a decent number of results about how to do this.
     
  18. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    We just picked this up for our project Hearts of Oak and it has solved a lot of our needs except for the last little one of moving stars. Is there a way to make the stars move in sync with the time easily?
     
  19. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    You can rotate the "Space" child game object as you wish to do this. Now that I think about it though, it would probably make sense to support this out of the box. I'll read up on how this works in real life. It shouldn't be perfectly in sync with the moon but somewhat the same direction I guess?

    EDIT: I just implemented optional moving stars, they'll be part of 2.2.0 - which I hope to be able to submit to the Asset Store this weekend.
     
    Last edited: Sep 5, 2014
    hopeful and CaptainMurphy like this.
  20. Lupin500

    Lupin500

    Joined:
    Mar 6, 2012
    Posts:
    25
    Thanks that solved my problem!

    I'd like to also ask you if there are any issues building for Windows with TOD? I didn't have any problems when I built my Mac app but I got these errors when I switched to windows.
     

    Attached Files:

    • Win.jpg
      Win.jpg
      File size:
      187.1 KB
      Views:
      897
  21. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    There are no known issues on Windows with Unity 3 and 4. Have you tried rightclicking the shader folder and selecting "reimport" to recompile all shaders?
     
  22. Lupin500

    Lupin500

    Joined:
    Mar 6, 2012
    Posts:
    25
    That was easy! All good now, thanks. And by the way your product is really great.
     
  23. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,360
    Is it possible to have same saved states of day (like 1-2 sun lights per case, 2 to 4 different lighting cases per time of day) and lerp though those, without nessesarilly turn the sun correctly ?

    Having a 100% correct cycle and sun direction will not always give me the result i want artistically, so is there a way to bypass that restriction and have the exact sun position/color i want in certain times (and auto lerp the in between) ?
    .
    Thanks
     
  24. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,122
    Hi, I have a game using your TOD plugin. Problem is the player can move from above the sea to under the sea where I set the fog density and colour etc to mimic being underwater. BUT your plugin seems to draw the sky dome on top of the fog. or put another way the fog doesn't effect the sky at all. What am I doing wrong?
     
  25. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    Sorry for the late reply - for some reason I didn't get an email notification for the last two replies to this thread.

    That's a fairly specific use case. I think it would be best for you to write a simple script that does this yourself since it's impossible for me to cover every specific use case. The way you'd go about this is disable the time progression in the TOD_Time script and manually call Mathf.Lerp on Cycle.Hour etc. It should be a very simple script to write if I understand your request correctly.

    Fog cannot affect the sky dome since otherwise you'd also have it obstruct the sky when above water. To test this you can comment out the line "Fog { Mode Off }" in the shaders. I would recommend placing geometry around your water which in turn is affected by the fog and can be used to obstruct vision. An even better way would be to use image effect fog (I think it's called "Global Fog" in Unity) and apply this when underwater.
     
  26. bbedwell

    bbedwell

    Joined:
    Nov 5, 2012
    Posts:
    37
    Trying to use this with uSequencer. It would be nice to be able to jump to specific times of day for each event.
     
  27. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    I don't own and never used uSequencer, which is why I currently have no plans to add official support for it. Given that Time of Day uses standard C# classes and variables I feel like it should be fairly easy for uSequencer to interact with it via custom events or whatever other interface uSequencer offers.
     
  28. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    Update 2.2.0 has finally been approved after more than 1 week in Asset Store review. Sorry for the delay - it is now available for download!
     
  29. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    I love the stars moving! Thanks for adding that.

    I am not sure if this is a bug, but the moon cycles are not aligned with the path of the sun/moon cycles. Sometimes the moon texture is up to 90 degrees off from the path it is on which makes it look a little odd.
     
  30. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    I don't think I understand what you're saying. Are you talking about the moon position or the moon rotation? The position will always be opposite to the sun if you set Moon.Position to "OppositeToSun" and will use its real-life position at the current date if you set it to "Realistic" - the rotation of the moon is kind of random since I don't keep it from rotating around the view direction vector, is it possible you're talking about this?
     
  31. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    Our setup is currently on Realistic, which is excellent, just the phase is turned out of whack.

    I'll try to explain a bit better. When the moon is lit, it is done so in the (nearly) same orbital plane as the sun. So the line that is cast for shadows is perpendicular to the orbital plane. As it is now, the moon is lit, but the light/shadow on the texture is in a different axis than the current plane of movement of the moon. In essence, the phase of the moon should be turned so that it is perpendicular to the movement of the moon across the sky.

    It is fairly minor, but the perfectionists in our game will surely catch it.
     
  32. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    So basically - the dark side of the moon is not always opposite to the direction the sun is at, which is also the direction of the path the moon is traveling on?
     
  33. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    Yes, that is a better way to explain it! Too much Kerbal Space Program for me I think... ;)
     
  34. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    Should be possible for me to fix this. I'll look into it as soon as I find the time.
     
  35. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    I fixed this just now. It's not perfect since the moon phase itself is calculated in that somewhat hacky way of iterating it over the course of one month, but the phase now always points in the direction (or the opposite direction) of the moon orbit.

    I also went on a journey to fix the banding of the atmosphere colors that was especially visible towards nighttime:
     
    CaptainMurphy and hopeful like this.
  36. Morfeuskiev

    Morfeuskiev

    Joined:
    Oct 10, 2013
    Posts:
    122
    Within a few weeks i tested your assets. I made a choice between environments gator and time of day. Your asset is win. Fast, Easy to learn, Stable and clean code. If you make very beautiful cloud system - Time of day has been very
    incredible system of day. Thanks you for your works. Waiting for big next update ;)

    With Best Regards, Leonid.
     
  37. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    I think this asset has really helped our project. I, too, would like to see some more cloud variety, maybe some simple weather added as well.
    Also, is there a way to put in realistic star layouts? even if we could just add in another layer on top of the tiles to give us some base constellations. Our game is seafaring so we would love to be able to sail by the stars.
     
  38. Kognitive

    Kognitive

    Joined:
    Mar 14, 2014
    Posts:
    7
    Just bought Time of Day and it's as fantastic as I'd hoped! One thing I'm confused about - I don't have a demo scene? has that been removed from the pack or do I need to request it?
     
  39. Morfeuskiev

    Morfeuskiev

    Joined:
    Oct 10, 2013
    Posts:
    122
    But for what? Time of Day is very easy and simply. Throw prefab Skydome on scene and....... and that is all ;)

    and one question:
    I have one problems with Projector of clouds shadow with Suimono water. Water is not work (invisible). When i click to projector and make layer mask to Everything, but not terrain - works fine. Enable only water layer is not fix problems. This is problems of suimono water shader?
     
  40. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,360
    I am that close to buying this one :), looks really sweet.

    Just need some more clarifications

    What are the big differences from this asset ?

    https://www.assetstore.unity3d.com/en/#!/content/8491

    Seems to have scaterring and orbits as well, i think it has clouds too (not sure). If the scaterring method is superior in Time of Day, would be good to know, so i pick up the top asset

    Also what kind of weather is supported ? For example does it support rain, lightning storms etc or is only related to the cloud setup and the other effects should be from another pack ? Is ti similar to Unistorm in that regard ?

    Thanks
    .
     
  41. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    I'm still hoping to get some work on the clouds done this year. So much to code, so little time...

    You can add hero stars fairly easily by rendering them at render queue position "Transparent-485" with any transparent shader you like. Just add some quads as child objects to the sky dome, rotate them towards the center and attach such a shader.

    I removed the demo scene a few updates ago since it was horribly outdated and little more than a Unity terrain and water plane from the standard assets. I'm working on a new demo scene in Unity 5 to show off the new ambient light and reflection features, which I'll hopefully upload somewhere soonish.

    Cloud shadows are using the default Unity projector, so there's probably not much I can do to fix this. You can test if the problem happens with any Unity projector just to make sure it's not related to TOD.

    Well, I don't own the linked asset so I can't really speak for it. Everything you have to know about TOD can be found in the docs and the Asset Store reviews - if you have any specific questions feel free to ask. Personally I think the biggest selling point of Time of Day is the fact that I update it extremely regularly. It already has full support for Unity 5, including all the new ambient light and reflection features.

    Out of the box weather is only atmospheric, meaning it adjusts cloud and atmosphere parameters. I added some example scripts you can attach to particle effects so that they're automatically faded in and out for the various weather types. There are lots of particle effects to use for this on the Asset Store.
     
  42. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,360
    Great, thanks for the clarifications.

    So essentially i could completly bypass Skyshop in Unity 5 and your system will integrate with Unity 5 IBL and all in real time ?

    That would be amazing :)
     
  43. Kognitive

    Kognitive

    Joined:
    Mar 14, 2014
    Posts:
    7
    OK no problem. I'm new to coding and so I was looking to see how you implemented the gui sliders and buttons. Is that a script you can make available to me? I'm happy to send my invoice number if required.
     
  44. Evil_Echo

    Evil_Echo

    Joined:
    Sep 30, 2011
    Posts:
    48
    The new features for Unity 5 are going to be awesome.

    I know it's still on the docket somewhere, getting support for multiple suns and moons. A scene with some world like Tatooine screen-capture-6.png
     
  45. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,122
    This will most likely be of Interest. :)
    http://forum.unity3d.com/threads/re...ds-and-time-of-day.262439/page-2#post-1768757
     
  46. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    Essentially this, yes.

    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_Weather.CloudType.None.ToString(),
    13.         TOD_Weather.CloudType.Few.ToString(),
    14.         TOD_Weather.CloudType.Scattered.ToString(),
    15.         TOD_Weather.CloudType.Broken.ToString(),
    16.         TOD_Weather.CloudType.Overcast.ToString()
    17.     };
    18.  
    19.     private string[] weatherTypes = {
    20.         TOD_Weather.WeatherType.Clear.ToString(),
    21.         TOD_Weather.WeatherType.Storm.ToString(),
    22.         TOD_Weather.WeatherType.Dust.ToString(),
    23.         TOD_Weather.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_SunShafts>();
    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_Weather.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_Weather.WeatherType)weatherType;
    97.  
    98.         GUILayout.FlexibleSpace();
    99.         GUILayout.EndVertical();
    100.         GUILayout.EndArea();
    101.     }
    102. }
     
    Kognitive likes this.
  47. Kognitive

    Kognitive

    Joined:
    Mar 14, 2014
    Posts:
    7
    Brilliant! Very much appreciated plzdiekthxbye.
     
  48. shanemburger

    shanemburger

    Joined:
    Oct 15, 2014
    Posts:
    3
    Newbie question...
    I am using the new 4.6 UI. I would like to link a slider in the UI to the Time of Day Cycle/Hour parameter (and perhaps others), but Cycle/Hour doesn't appear to be an exposed parameter within the slider script area for to link it to. Is there something I can do?
     
  49. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    TOD_Sky.Instance.Cycle.Hour should be accessible from any script. What error are you getting when you try that?
     
  50. shanemburger

    shanemburger

    Joined:
    Oct 15, 2014
    Posts:
    3
    This is probably because I am new to Unity. The 4.6 UI doesn't require much scripting (I have experience scripting in other tools, but not Unity yet), as all I have to do in the 4.6 UI interface is link it to a value in the object. Perhaps I need to spend more time with scripting in Unity before I bug you much more!