Search Unity

Time of Day - Dynamic Sky Dome

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

  1. AADProductions

    AADProductions

    Joined:
    Aug 16, 2012
    Posts:
    30
    No that wasn't a typo. I made some changes to TOD_Cycle way back when to link everything up to my world clock, and I haven't wanted to upgrade since (until this one issue) it's been the most stable bug-free third party Unity asset I've ever used.

    [EDIT: I've just been sent another video which makes me think it's not TOD after all. It may be a global fog system. If I'm wrong I'll post again - if not then sorry for the bother.]
     
    Last edited: Jan 18, 2015
  2. mittense

    mittense

    Joined:
    Jul 25, 2013
    Posts:
    168
    Is there any particularly quick way of getting TOD scattering working well with deferred rendering U5? I'm trying to modify the GlobalFog shader to use the ScatteringColor function but my results have not been... stellar.

    Closest I've come is modifying the global fog's fragDistance function:

    half4 fragDistance (v2f i) : COLOR
    {
    float dpth = Linear01Depth(UNITY_SAMPLE_DEPTH(tex2D(_CameraDepthTexture,i.uv_depth)));
    float4 camDir = ( /*_CameraWS + */ dpth * i.interpolatedRay);
    float fogInt = saturate(length( camDir ) * _StartDistance.x - 1.0) * _StartDistance.y;
    return lerp(ScatteringColor(camDir), tex2D(_MainTex, i.uv), exp(-_GlobalDensity*fogInt));
    }
     
  3. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    Hi, Is the moon phase accurate? If not, do you know how I'd be able to make it accurate? Thanks
     
  4. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    This calculates the sky color from the world space view direction:
    Code (CSharp):
    1. float3 skyDir = normalize(mul(TOD_World2Sky, wsDir)).xyz;
    2. half4 fogCol = ScatteringColor(skyDir);
    You can then simply replace unity_FogColor or the input fog color with fogCol.

    The moon phase should be accurate withing 1-2 degrees in the current release.
     
    mittense likes this.
  5. Sendatsu_Yoshimitsu

    Sendatsu_Yoshimitsu

    Joined:
    May 19, 2014
    Posts:
    691
    Did TOD_Time get an overhaul with a recent update? I used to have an event that listened for ProgressHour and ProgressMinute to be True, and it's pretty critical to one of my systems... any advice on what to look for in the new TOD_Time to tell when the hour or minute get incremented?
     
  6. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    I don't think I ever officially provided that functionality. Events for this sort of thing are actually on my list for 3.0.0 features - so if you can wait a few more days (I'm still going for an end of January submission) I would recommend waiting for that.
     
    hopeful likes this.
  7. Sendatsu_Yoshimitsu

    Sendatsu_Yoshimitsu

    Joined:
    May 19, 2014
    Posts:
    691
    I'm in no hurry, and events for time changes would be awesome- that's what I jury-rigged myself, and a more professional version of that would be awesome, so take your time knowing that I and probably tons of other uses really appreciate the continuing development. :)
     
  8. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    Thanks for the reply.

    I have another question, probably really simple or already covered but I'm having an off day. :)

    How can I take the TimeOfDaySky.Cycle.Hour value and convert it to a 24 &/or 12 hour time string?

    Thanks
     
  9. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    PSA: Unity 5 beta 21 contains fairly major changes to reflection probes and will therefore break compatbility with Time of Day. Since 3.0.0 is around the corner I will not submit an updated version of 2.3.5 to reflect that change, but instead you can send me an email with your invoice # and receive either a patched version of 2.3.5 or the current internal prerelease of 3.0.0 if you want to upgrade to beta 21. I do not know when exactly beta 21 will be available for download, but I assume it will be some time next week.

    @derkoi You can access Cycle.DateTime which allows you to get every time / date string you can imagine: https://msdn.microsoft.com/en-us/library/system.datetime(v=vs.110).aspx
     
    elbows likes this.
  10. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    Excellent, thanks. I knew it'd be simple.
     
  11. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    Unity 5 beta 21 is now available to download, I've email you my invoice number. Thanks
     
  12. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    Since I already got quite a few requests from people who would like to receive the 3.0.0 prerelease (so far nobody seems to be interested in the patched 2.3.5 version, hehe) I setup a mailing list. I will send out a download link later today.
     
  13. Becoming

    Becoming

    Joined:
    May 19, 2013
    Posts:
    781
    I was asked if my upcoming asset Horizon[ON] works well with Time of Day, so i gave it a try and i have to say Time of Day rocks :) I think the clouds could be improved a little but thats criticism on a very high level. Overall, fantastic product and very easy to use. I made a short video to showcase Horizon[ON] but since half of the screen is covered by TOD (and imho showcases it quite well) i thought i post it here too:

     
  14. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    Very nice video! Do you have a webplayer demo as well? It would look even better with 3.0.0 and its aerial perspective / planet shadowing, so email me with your invoice # to receive the prerelease if you're interested.
     
  15. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Hi there,
    I just saw that 3.0 is around the corner. A few questions:
    1) Will it still be mobile friendly? I need it to run on iPhone 4
    2) Feature list of what will be included on 3.0 ?
    3) Any hopes of including lighting effects on the cloud? I would love you have weather effects included but if not, at least the sky should have some lighting effect because it effects the whole sky. The ars package done by a third party is not good for us because on every ToD update, it breaks and they have to keep playing catchup. We can write our own mobile system for rain/snow but we need to be able to light up the sky on lighting in a realistic way and keeping it mobile compatible.
     
  16. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Any idea if god rays are broken with the 3.0 pre-release and Unity 5 b21? I dont seem to be able to get them working on a scene that used to work with previous unity beta and time of day.

    Aside from that, it all looks rather lovely to me, nice :)
     
  17. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    738
    Hello, I an interested in ToD,
    How is the performance on iPhone 5?
    I was thinking on baking lightmaps, but having a ToD might be cool as well.
    But if it takes a lot of draw calls on complex scene, hmm..

    Will there be a demo on the dynamic weather?
    Is there an included particles? like snow storms?

    Can you have more than 1 moon?

    any chance on demo.apk?
     
  18. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    Using the same settings (same cloud quality, same vertex count, per-vertex scattering color, no cloud billboards) 3.0.0 should require less CPU time and a tiny bit more GPU time than 2.3.5, which can be reverted by manually disabling multiple scattering in the scattering shader include file - which will most likely not be required since the difference really is very small in the per-vertex scattering mode. Cloud billboards batch dynamically, so they are mobile friendly as well - but on an iPhone 4 you'll still pay for the overdraw / alpha blending, so depending on the project it could be a good idea to stick to either only cloud layers or only cloud billboards and use the free processing time for something else.

    The current changelog is the following:
    • Added new atmospheric scattering model (supports planet shadowing)
    • Added ColorRange parameter to specify whether or not to output colors in high dynamic range
    • Added SkyQuality parameter variable (can be per-vertex and per-pixel)
    • Added dynamically batched normal mapped billboard horizon clouds (see Clouds.Billboards)
    • Added inspector variable tooltips
    • Added events that are fired when a year, month, day, hour or minute have passed to TOD_Time
    • Added an image effect that renders atmospheric scattering and aerial perspective in a single pass
    • Added profiler samples to TOD_Sky
    • Improved inspector variable interface by using property drawers
    • Improved inspector variable verification by using property attributes
    • Improved cloud layer shading
    • Improved shader property update performance
    • Fixed errors in Unity 5 Beta 21 (this means Beta 20 is no longer supported)
    • Changed all textures from PNG to TGA
    • Changed all color inspector variables to gradients
    • Changed sun shader to a procedural shape instead of a texture
    • Removed a number of now unused parameters
    Not sure what you mean exactly, but clouds receive light and atmosphere fogginess affects the light source intensity as of 2.3.5 if I'm not mistaken. However, Time of Day does not and probably will never provide particle effects out of the box.

    Is this in a standalone build? The prerelease I sent out yesterday has the issue that Unity 5 strips the PP shaders if they're not manually added to the "always include" list in the graphics settings. This is already fixed in the latest internal version.

    An iPhone 5 shouldn't have any performance problems with Time of Day. It's actually possible to achieve solid 30 FPS on an iPhone 4 / iPad 1 in a full game with Time of Day on the lowest settings and from iPhone 4S / iPad 3 performance upwards (including iPad 2 due to the non-retina display) you should easily be able to do 60 FPS if your scene is sufficiently optimized.

    Dynamic lighting with Time of Day really shouldn't be a problem, especially not on an iPhone 5. Realtime shadows are a different story, but if you don't need a dynamic day / night cycle you can set TOD to a static time and bake lightmaps from that.

    I'm not planning to add particle effects to Time of Day - there are various particle effect packages on the Asset Store that integrate with Time of Day with no problems at all.

    You cannot let Time of Day calculate the orbit of a second moon out of the box, but you can place a second one yourself.

    Probably not since I'm not really up to date on iOS development right now.
     
  19. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    No, inside the editor. I havent been able to narrow down the issue further yet, will keep playing.
     
  20. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    You are correct - the alpha channel isn't cleared correctly and the god rays assume there are clouds everywhere. I'll investigate and fix it, thanks for the report!
     
  21. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Thanks very much for sharing the 3.0 version early with us, and for quickly finding the problem I reported :)
     
  22. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    I meant like a storm lighting. A bright shot on the clouds, like where there is a storm. I need that, because I can do the lighting bolt myself and the rain and all that, but the clouds need to be illuminated in some kind of realistic way.
     
  23. Olander

    Olander

    Joined:
    Sep 13, 2014
    Posts:
    405
    Have updated to 2.3.5 and Time of Day continues to render very nicely. I am very much looking forward to 3.0!!

    One quick question on this. How difficult would it be to have a 2+ Moon type of world with Time of Day? I have 2 moons (one medium sized brownish orange and one more like our moon but bluer and much larger).

    Cheers
     
  24. AdamGoodrich

    AdamGoodrich

    Joined:
    Feb 12, 2013
    Posts:
    3,783
    What is Horizon ?
     
  25. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
  26. AdamGoodrich

    AdamGoodrich

    Joined:
    Feb 12, 2013
    Posts:
    3,783
  27. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    3.0.0 won't bring anything new in that regard, so short of patching the cloud shader yourself some sort of halo or image effect (for example apply bloom to the lightning bolt) is probably your best bet for now.

    Is anyone else interested in doing something like this?

    That mainly depends on how your second moon should move. You can either manually add the orbital parameters of the second moon (which would require you to manually add your second moon to the celestial computations in TOD_Sky.cs) or you can simply place relative to the first moon. Generally speaking I would recommend doing it the second way since that way you don't have to touch the TOD code files on every update. The method TOD_Sky.OrbitalToLocal might be useful for this, but you can also make the second moon a child object of the first moon if you don't need their positions relative to each other to change. For the material of the second moon you should probably use the same one as the first moon to be future proof and simply adjust the texture in a custom script using MaterialPropertyBlock. I might add support for doing this in a more easy way in the 3.x cycle, but I wouldn't wait for that if you need it fairly soon.

    Update regarding the public release of 3.0.0: I haven't managed to submit it to the Asset Store last weekend, but I'm determined to do so later this week or the upcoming weekend. Until then the offer for a mailing list invitation to receive the current internal build still stands - just contact me with your invoice # and if possible your Google account email.
     
  28. Olander

    Olander

    Joined:
    Sep 13, 2014
    Posts:
    405
    Thank You very much for the Moon advice. I shall see what I can do. When I figure it out the info will be updated on this forum.

    The Clouds and Lightning. Actually, with UniStorm 1.8.1 I am doing that now. I am removing their Sun and Moon and replacing them with Time of Day. The lightning flashes that take place do illuminate the clouds. The ARS weather system for Time of Day also illuminates the clouds rather well but ARS is fickled to get working correctly over the long run. UniStorm had fairly horrible lighting but excellent weather and temperature.

    When I figure this out I shall post the info in this forum. Should not be too long really....perhaps by end of this week.

    Cheers
    O
     
  29. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    I don't find any info on the thread about this... are clouds "flyable" ? I'm thinking of using this on a flight game but it would be awesome if you could fly above and through the clouds.
     
  30. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    I was lost... to get it working you don't use the clouds from TOD ? What I understood on your message is that all you use are the Sun and Moon from TOD and everything else from UniStorm
     
  31. Olander

    Olander

    Joined:
    Sep 13, 2014
    Posts:
    405
    Actually there are 5 cloud solutions being tested.
    1) Time of Day
    2) UniStorm (v1.8.1 has improved their clouds but not as solid as option 4)
    3) my own Shader solution....looking very promising.
    4) Storm Effects....so far the best solution for clouds. www.assetstore.unity3d.com/en/#!/content/5048
    Options 3 and 4 are actually really nice when up close to the clouds. Closest to actual flyable clouds I have seen.

    Of note: trueSky Alpha www.assetstore.unity3d.com/en/#!/content/17304
    has amazing clouds and sky with shadows and all. It is expensive and made for PC/Mac/Xbox1/PS4 high end machines.....Time of Day has better light rendering in my opiinion!!

    As to the Lightning light effect all clouds light up fine. This includes simply making the light flash with no actual bolt coming from the clouds. Setting up the night to quite a bit darker than default makes night storms very nice.

    Once I figure the solution I find the best I shall share the results with the Time of Day fanatics.

    Lastly....I really WANT horizon[ON]!! :)
     
    elbows likes this.
  32. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    I just sent out the third and final prerelease of Time of Day 3.0.0, which will be submitted to the Asset Store on Monday if no unexpected issues come up. I also updated the docs and demo scene on the official website.

    The demo was built with Unity 5 RC1, but it in theory it should work with previous versions of the Unity 5 webplayer. I'm also still planning to get a new terrain / landscape demo scene up in the near future, but for now this minimal demo will have to do.
     
    elbows likes this.
  33. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,684
    The new demo looks good! Cloud colors get a bit odd around sunset, though.
     
  34. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    Cloud base colors use a gradient now, so you have full control over it. That being said, after having a closer look I agree that the gradient I setup in the demo looks a tad weird around sunset. I'll tweak it when I have more time - just hacked this scene together to have something to show today.
     
    hopeful likes this.
  35. Trollvahkiin

    Trollvahkiin

    Joined:
    Aug 3, 2013
    Posts:
    15
    Hey, how do I setup up sun flare?
     
  36. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    There's of course the possibility of adding lens flares to the "Light" child object of the sky dome. However, if you're using Unity Pro, I would really recommend doing those kinds of effects via image effects, especially since in those classic lens flares are only blocked by colliders, not by shaders that write to depth.

    I mention a couple of recommended image effects in the docs, and especially "SE Natural Bloom & Dirty Lens" is highly recommended as it does everything you need to make HDR in Unity yield the results you want. What you basically do is set the sun and moon mesh brightnesses to values that are fairly high (in the 100s for the sun and high 10s for the moon) and let the image effect do the rest.
     
  37. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    Time of Day 3.0.0 is now on the Asset Store!
     
    elbows likes this.
  38. Image3d

    Image3d

    Joined:
    Jun 20, 2008
    Posts:
    155
    Just update Unity to 5 RC01 and found the folowing problem:

    Assets/Time of Day/Assets/Scripts/TOD_Parameters.cs(567,16): error CS0246: The type or namespace name `ReflectionProbeClearFlags' could not be found. Are you missing a using directive or an assembly reference?

    Can you take a look. It worked in UnityB18, but give this error in B22 and latest RC01.
     
  39. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    Is it possible you haven't upgraded to Time of Day 3.0.0 or the upgrade failed for some reason? Because I'm on RC1 and cannot reproduce this. I also double-checked that the UnityEngine.Rendering using directive is present in TOD_Parameters, which is the case.
     
    Brainswitch likes this.
  40. Image3d

    Image3d

    Joined:
    Jun 20, 2008
    Posts:
    155
    Thanks for your fast reply. I removed the imported TOD and import it again.

    No errors now. Great job !
     
  41. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    I believe it is possible there is an Asset Store bug. Not sure which versions of Unity it affects but this is what just happened to me with 5 RC1:

    Inside a relatively empty project thats not got Time Of Day in it at all.
    Open Asset Store Window
    Click to update TOD from 2.3.x to 3.0
    It indicates that it has downloaded ok.
    Press import button (or use the import window that opens automatically after update downloaded) - No good, get the errors mentioned above.

    Close Asset Store Window
    Delete Time Of Day Folder from project
    Open Asset Store window
    Press Import - This time it works fine.

    So my guess is that if a package update has a different filename to the previous version already downloaded, the import button still tries to import the previous version, if you press the import button during the same Asset store window session as the one you downloaded the update in. Until you close the Asset store window and re-open it, when it then imports the new version as it should.

    It's only a guess, but its all I could come up with given that I was using a project that had no TOD folder in it at all before I tried to import the new version.
     
    Last edited: Feb 11, 2015
  42. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    I just recreated my experience (by deleting the newer version from asset store download location on hard drive and then using asset store to update again) and I reckon I was right about the issue.

    I'm not terribly good at reporting bugs to Unity, anyone fancy reproducing the above and letting them know?
     
  43. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    I sort of reproduced it last night. Had a project with the old TOD in it, I removed it, checked the version in the asset store page and downloaded the new version, saw that same error above, removed it, downloaded it again, same error. I ended up removing TOD, restarting Unity, reimporting all assets, then doing another download and import. That seemed to have fixed it for me. Seems mine was just a roundabout method that you figured out, lol.
     
  44. dempseyg

    dempseyg

    Joined:
    Oct 30, 2013
    Posts:
    4
    Hi, I am working on a project where I need the day/night scene to transition by moving a GUI slider - I am working off a script that creates a GUI slider allowing the user to adjust the date and time. The sun position is based off longitude and latitude, the time of day and the time of year. This is linked to a shader on the the skydome, but clients have commented on the darkness of our sky in demos. I am interested in buying a copy of TOD that will work with Unity5 (and 4.5) but I wanted to be sure that it is possible to edit the Time and Date function to be run with a guislider ? (Sorry if this seems like a basic question, I have just inherited a bunch of project scripts and shaders which I want to update to Unity 5 but I am having problems upgrading the old scripts for future projects. TOD looks amazing and I am trying to demonstrate that it is what we want, but the higher ups want to ensure that it will seamlessly add to our current project setup and we call call the GUIslider from the TOD script . - This is a video showing what we currently have, view from 2m3s (I can't get the link to jump to it)
     
    Last edited: Feb 11, 2015
  45. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    v3 is amazing

     
  46. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    Is there a way to get the sun/moon size to change based on the proximity to the horizon? I am looking to replicate the function in CryEngine that would give you a gradient for it so that sunrise and sunset meshes were larger.
     
  47. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    Yes, very easy. You can influence the mesh size by the height of the sun - no problem
     
  48. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    Time of Day automatically calculates the correct sun and moon position from time, longitude and latitude. This means all you have to do is set those values. This can of course be done with a GUI slider. For example, the value you have to adjust for the time would be TOD_Sky.Instance.Cycle.Hour or alternatively TOD_Sky.Instane.Cycle.DateTime if you prefer that. The position longitude and latitude would be TOD_Sky.Instance.World.Longitude / Latitude.

    As Cascho01 said you can adjust TOD_Sky.Instance.Moon.MeshSize according to TOD_Sky.Instance.MoonZenith (which is an angle in degrees from 0, or moon at zenith, to 180, or moon opposize to zenith) - the same is true for the sun. I might add some sort of gradient for values as well (the same way I did for colors), but if I do that I'd like to do it properly, i.e. the way the Shuriken particle system does it. Until then a simple custom script should do.

    Awesome screenshot - all it needs are some horizon clouds! (see Clouds.Billboards)
     
  49. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    Just tried them.
    To be honest, I think they´re not that beautiful right now, maybe due to lack of customisation parameters.
    They´re moving like a rotating ring, so they´re partly "colliding" with the other clouds which are moving directional.
    In the end - what´s their purpose? The main clouds are very fine to me as they´re right now.
    All you could try is to let them react more to the suns position/color/intensity so that we get more realistic sunsets. Just my opinion :)
     
    Last edited: Feb 13, 2015
  50. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    Could you explain, how the gradients exactly work?
    The very left of the gradient corresponds to maximum sun height?