Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

Time of Day - Dynamic Sky Dome

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

  1. SIV

    SIV

    Joined:
    May 7, 2014
    Posts:
    198
    Hello,

    It looks cool, i was wondering if there is a way to turn on lights when night come like with unistorm ? like a way to enable/disable game objects in scene when day or night come.





     
  2. Dreamwriter

    Dreamwriter

    Joined:
    Jul 22, 2011
    Posts:
    472
    Hi,

    I recently started working on a project using your plugin - seems great! The project is using a really old version of Time of Day (1.8!), and recently at night all surfaces started being a bright blue. Does that sound like a problem caused by using an old version with Unity 5.6? It might instead be caused by a change I made to Unity settings, like DX 11, deferred rendering, shader changes, etc. but I'm trying to eliminate possibilities.

    Edit: I just realized, this has to be a newer version of the plugin, because it has some things mentioned in future updates, like renaming "Sky Assets" to "Assets", it's just an old version of the docs I guess. Is there any way to tell exactly what version of the package this is in this project?
     
    Last edited: Jun 19, 2017
  3. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    There are some example scripts to do this in the "Examples" folder. For instance. check out TOD_LightAtDay to toggle a light.

    The documentation is where the version is included. I do recommend upgrading when you're using the latest Unity releases, preferably by deleting the old version before importing the new one.
     
  4. mons00n

    mons00n

    Joined:
    Sep 18, 2013
    Posts:
    250
    @plzdiekthxbye is there any quick way to get the moon phase? I see in the doc changelog it was removed at some point...
     
  5. Leoo

    Leoo

    Joined:
    May 13, 2013
    Posts:
    96
    @plzdiekthxbye Hello, is there a way to change the "start distance" of the Atmospheric script?, I want the effect to be strong but starting a little bit farther from the camera is that even possible :) ?
     
  6. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,864
    In one project I'm suddenly seeing a crazy strange issue with lighting. The Light object in my SkyDome is being forced to Intensity 0 by TOD_Sky script and it doesn't change. I have my Day light intensity setting at 1.2 and I have time progressing at 1 minute for full day to see if lighting changes, but the intensity remains at 0 the entire time. I've never seen this before. Any ideas what may cause it?

    [EDIT]
    Using Unity 5.6.2f1

    [EDIT 2]
    I found it. Setting a high fogginess does this. My bad. Sorry.

    [EDIT 3]
    Still, though, if fogginess is set to 1 then lighting remains same no matter what time of day it is. It's sort of a dim looking scene, but neither night or full day. Seems like an issue there still that light doesn't change at all.
     
    Last edited: Jul 1, 2017
  7. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    There's no longer a property for this since it's now calculated from the angle between the sun and the moon like in real life. You should be able to calculate it from the dot product of the moon-to-sun vector and the sun-to-camera vector. Will put this on my list for the next update.

    That's not possible as of right now, but it should be fairly easy to add so I'll put it on my list.

    The ambient light will still change as time progresses, as will the brightness of the scene. It makes no sense to get shadows from the sun or moon if they are 100% covered by fog, so that's why the directional light has to be disabled.
     
    Leoo, hopeful and mons00n like this.
  8. mons00n

    mons00n

    Joined:
    Sep 18, 2013
    Posts:
    250
    Are these currently exposed or something I have to calculate? I see SunDirection and MoonDirection but those obiously aren't it.
     
  9. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    Components.SunTransform.position / Components.MoonTransform.position should do the trick. Just subtract and normalize to get the vector.
     
  10. mons00n

    mons00n

    Joined:
    Sep 18, 2013
    Posts:
    250
    Awesome thanks for the quick reply! I really could not find a place where the moon light intensity correlated with the moon phase so I wanted to add that in for more dynamic nights. This seems to work so far if I consider the TOD night light intensity to be the intensity at a full moon (inserted at line ~573 of TOD_Sky.cs):
    Code (CSharp):
    1.  
    2. Vector3 moonSun = (Components.SunTransform.position - Components.MoonTransform.position).normalized;
    3. Vector3 sunCam  = (Components.SunTransform.position - Camera.main.transform.position).normalized;
    4. float percent = 1f - Mathf.Acos(Vector3.Dot(moonSun, sunCam) / (moonSun.magnitude * sunCam.magnitude)) / 1.5708f;  //1.5708 is 90 deg in radians
    5. lightIntensity = Mathf.Lerp(0, percent * Night.LightIntensity, MoonVisibility);
    6.  
     
    Last edited: Jul 12, 2017
  11. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    Yeah, you are correct - this seems to have been accidentally removed when the moon phase calculations changed, I will add it back in together with the moon phase getter.
     
    hopeful and mons00n like this.
  12. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    1,885
    ToD is truly awesome. Hover over time the night sky gets a tad boring. Is it possible to add a milky way somehow? And shooting stars?

    I toyed around with the clouds. I guess in the cloud layer one could also add an aurora / northern lights effect. Does anyone know how to do this. Or might it be possible to add an aurora as additional feature? :D
     
  13. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    You can enable the "Space" child game object of the sky dome and assign a cubemap of your choice to the "Space" material so it will be visible at night. There are various cubemaps of the milky way available on the internet.
     
    Rowlan likes this.
  14. Slick_Nick

    Slick_Nick

    Joined:
    Jan 4, 2014
    Posts:
    36
    Hello!

    I'm currently building a game where you can play split screen on the same TV.

    I have been using another procedural sky for a previous project, and just like your solution, the dome is tracked by the "main cameras" transform.

    So i thought i could split up the component and have a "simple sky version" for each secondary player and use the light etc from the "main sky component" and then just render the dome of clouds etc for the other players by just layering the rendering of each player's camera to use one dome each..

    But that other sky solutions code structure is truly horrific, even an Italian chef would get scared by that spaghetti :)

    So my question is, how much of work you think it would take for me to adjust your package, to make it support a split screen game mode.

    Best regards /Niklas
     
  15. GamerPET

    GamerPET

    Joined:
    Dec 25, 2013
    Posts:
    367
    Are there any setting you would recommend?
    I just dragged and dropped the prefab on the scene and changed the latitude/longitute.



    Everything looks a bit to blown out for me right now. What is the firs thing you would recommend to tweak?

    Thanks <3
     
  16. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    You are working in linear / HDR space - so you need a tone mapper / post-processor to do your final look.

    Easy way: download "Post Processing Stack" - it's free - and turn on the color grading. You'll immediately see rich detail in your sky. You can tune it from there with depth-of-field (focus,) etc.

    You are in for a treat - this is an amazing an relatively new area of game design.
     
  17. GamerPET

    GamerPET

    Joined:
    Dec 25, 2013
    Posts:
    367
    Good point. I was only setting the scene up, didn't had time to add camera effects yet.
    But thanks for the info, I will pay more attention now to the tone mapper. It really seems to be an important component :)
     
  18. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    Integration with Aquas:
    - creator of Aquas claims that it is "technically impossible" for Aquas to receiving TOD_Scattering because the water is transparent
    - I notice in the new post processing stack that pre-transparency and post-transparency "phases" are present

    Is it possible that integrating TOD_Scattering into the new post-processing framework will make it possible to show scattering properly within aquas?
     
  19. magic9cube

    magic9cube

    Joined:
    Jan 30, 2014
    Posts:
    58
    Hello,

    I'm guessing this has a very simple explanation; When i apply the TOD_Rays script to the camera it inverts the view. (sky on floor, ground in sky, etc) Any advice much appreciated.
     
  20. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    Supporting split screen should be fairly easy with Time of Day, but I haven't personally done it yet. There are two basic ways to do it, either you use two sky dome instances, one for each camera, and hide them from each other using layers, or you try to reuse one sky dome by moving it to each camera in OnPreCull() - for example via the TOD_Camera script.

    You can also run TOD in LDR mode, either by disabling HDR on your camera or by setting the "Color Range" inspector variable on TOD_Sky to LDR.

    I know for a fact that it's possible since we're doing it with the water in our game. Even with the post-transparency phase the water would still have to write to depth, so until that's the case there's no way to support these kinds of image effects. You can technically modify the water shader and manually sample the fog color like that, but I imagine it's only a matter of time until some other image effect or game mechanic will need the water to write to depth.

    I'll have to look into this. What version of Time of Day are you using? What version of Unity are you using? Are you using forward rendering? Are you using anti-aliasing?
     
  21. Redrag

    Redrag

    Joined:
    Apr 27, 2014
    Posts:
    159
    Is there a problem with moon position and phase currently. The moon seems to rise every night and always be full.
     
  22. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    This sounds like you have the moon position inspector dropdown on TOD_Sky (Moon -> Position) set to "Opposite To Sun" instead of "Realistic" - can you please check that?
     
  23. Redrag

    Redrag

    Joined:
    Apr 27, 2014
    Posts:
    159
    Sorry - should have checked that! Looks fantastic now.
     
  24. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    We just updated our Unity VR project to 5.6.2 from 5.3. Upon running our play scene we now have crazy GHOSTING from everything in the scene. I noticed we didn't have this issue in scenes without TOD so went back and come to find out its the Clear Flags option. TOD default of Solid Color causes this bug to happen. If I turn off the TOD_Camera script and switch Clear Flags to Skybox, the ghosting goes away. Using VIVE VR, the latest TOD and Unity 5.6.2 and Single Pass.
     
  25. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    That's interesting, albeit odd since solid color clear flags certainly shouldn't be causing any issues. I haven't tested VR on 5.6.2 but I was able to use TOD just fine out of the box with Unity 5.6.0 on my HTC Vive - can you maybe give that version a try? Also, does it happen in an empty project with just TOD in the scene?
     
    Tethys likes this.
  26. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    We were on 5.5.3 and went to 5.6.3 as we need some fixes for other shader assets that required that version.
     
  27. philc_uk

    philc_uk

    Joined:
    Jun 17, 2015
    Posts:
    87
    Does TOD work fine on Unity 2017.1/.2 ?
     
  28. olavrv

    olavrv

    Joined:
    May 26, 2015
    Posts:
    298
    We are using it on Unity 2017.3b10 - works 100%
     
    Tethys likes this.
  29. philc_uk

    philc_uk

    Joined:
    Jun 17, 2015
    Posts:
    87
    Too late - I bought it - enjoy the weather!
     
  30. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    Yes, all of the Unity 2017 releases that are currently available are supported.
     
  31. lanrosta

    lanrosta

    Joined:
    Oct 11, 2014
    Posts:
    26
    Is there a way to view the demo you have linked in the asset store in firefox or chrome anymore? All I see is the 'Unity Web Player Install Now' button. When I install it, it does not do anything, but show the same install button. I remember being able to view the demo in the web browser a year or so ago. I purchased the asset the other day, but wanted to refer back to the demo, but it just does not work anymore in browsers. Do you have a downloadable unity project of the demo that I can run in unity?
     
  32. backwheelbates

    backwheelbates

    Joined:
    Jan 14, 2014
    Posts:
    157
    Hi. Thanks I really love using this asset.
    Just have a question. After switching to the metal API on iOS the clouds are being drawn on top of everything. Is there anything I can do to fix this draw order?

    Thanks!!
     
  33. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    The browser plugin should still work in Safari on macOS, so there's a chance it also still works in Internet Explorer? I'll have to look into updating the demos to WebGL. If you want the UI script from the demo I can send it to you.

    That's interesting - can you try replacing the line "Queue"="Geometry+530" with "Queue"="Background+60" in the cloud layer shader?
     
  34. backwheelbates

    backwheelbates

    Joined:
    Jan 14, 2014
    Posts:
    157
    Thanks @plzdiekthxbye , Ill give this a try. I suspect that the metal api broke functionality for several other image effects. So Ill need to try this as well as look into other places it may have failed.
    All the best!
     
  35. lanrosta

    lanrosta

    Joined:
    Oct 11, 2014
    Posts:
    26
     
  36. czokka

    czokka

    Joined:
    Mar 14, 2017
    Posts:
    13
    Hey guys i baught this asset and its fantastic but im very stuck. i want to modify my world temperature based on wether its night or day. but i cant find any bools so i could theoretically say (if day == true -> start raising temperature)
     
  37. Nadan

    Nadan

    Joined:
    Jan 20, 2013
    Posts:
    341
    Hi, I recently purchased Time of Day. Looking good!

    I have one directional light in my 2.5D platform game for general lighting and in the Time of Day sky in the background. When it's night and gets dark I would like to lower the Directional Light Intensity. I'm trying to write a script that gets the "hour" from TOD_Sky or some other solution to know when the Intensity should be set at 0 (night) or at 1 (day). I couldn't access the "hour" variable yet with my other script. Any help how to do this?
     
  38. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    I sent you the demo scene UI script.

    The variables can be accessed by TOD_Sky.Instance.IsDay and IsNight.

    You can get the hour using TOD_Sky.Instance.Cycle.Hour or use the IsDay / IsNight booleans I mentioned above.
     
    Nadan likes this.
  39. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    808
    Provided we don't need time of day changes during gameplay, can this asset be used together with sky cubemaps? Basically, blending to traditional skybox instead of exclusively using procedural background based on scattering - for mountains, detailed high-altitude clouds and other elements like that.
     
  40. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    Cloud billboards are included by default and you can simply plug in your own textures there if you want. You can also use a custom cubemap at night - but it's blended out at day. It would be rather easy to change the "Space" shader that's used for the custom night cubemap so that it's visible at day as well, you'd just have to remove the "TOD_StarVisibility" multiplier and potentially change the render queue so it's rendered after the atmosphere instead of before it.
     
    hopeful likes this.
  41. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    808
    Thanks a lot! A followup question: I'd like to make all my custom transparent shaders correctly faded in the fog produced by TOD_Scattering effect (since I'd love to use it at high intensity in some situations like mornings or rainstorms). They seem to be rendered after it, so it's hardly the fault of the scattering effect and just has to be handled within semitransparent shaders themselves. That's simple to do for standard Unity fog, since it provides global variables you can compute fog intensity from, fading opacity of semitransparent shader fragments accordingly.

    If I feed density, falloff and zero level of TOD_Scattering effect into global shader float variables, and compute screen position + linear eye depth for a given shader fragment, how can I derive the fog density from those inputs to correctly fade out my semitransparent material?
     
  42. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    808
    hopeful likes this.
  43. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    All the required variables are already set as global shader parameters so you can easily sample the fog in any shader using the functions defined in the TOD_Scattering.cginc file. The function to sample the fog color and density in a single call is called AtmosphericScattering. If you just need the fog density you can also use the FogDensity function.
     
  44. Image3d

    Image3d

    Joined:
    Jun 20, 2008
    Posts:
    116
    How ca I have Time od Day sky to reflect on my water. The shader i am using has an reflection texture...
     
  45. SirTwistedStorm

    SirTwistedStorm

    Joined:
    Sep 20, 2015
    Posts:
    190
    You should be able to make any object reflect by using reflection probes, there's a ton of guides on YouTube.
    have a great day.
     
  46. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    The water shader really has to support Unity's reflection probes. You can also try feeding the render texture from the reflection probe into the shader if it supports setting a cubemap.
     
  47. AkinBilgic

    AkinBilgic

    Joined:
    Jun 14, 2016
    Posts:
    7
    Misaligned Stars?

    I'm running into a problem with the alignment of stars in my scene. Attached are two screenshots - one from Time Of Day with an incorrect position of the stars according to lat/long/utc + time settings. The second screenshot is from Stellarium, which has the same lat/long/utc + time settings is confirmed correct.

    Is there something I'm missing / have misconfigured in my settings? or is this a bug?
    Thanks!

    TOD_02.jpg TOD_01.jpg
     
  48. AkinBilgic

    AkinBilgic

    Joined:
    Jun 14, 2016
    Posts:
    7
    Any word on this? Thanks!
     
  49. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    Sorry for the late reply. I've been super busy for the last weeks since the game I'm working on left Steam Early Access on Thursday. I'll try to find some time to look into it this week.
     
  50. Kubic75

    Kubic75

    Joined:
    Jan 2, 2017
    Posts:
    83
    The bottom triangles of the Skydome-Mesh are not rendered here.
    Any solution?
     
unityunity