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

Time of Day - Dynamic Sky Dome

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

  1. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,191
    This is probably a camera issue. Try playing with your far clipping plane. You may also need to make an adjustment in the TOD camera component.
     
  2. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    Exactly this, try adjusting "DomeScaleFactor" on the camera component and make sure "DomeScaleToFarClip" is checked.
     
  3. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    Thanks for reporting this bug, and sorry again that it took so long for me to look into it. The good news is I've tracked down the issue and the fix will be included in the next update. In the meantime you can fix it yourself by replacing one line of code.

    Find this line in the TOD_Sky.cs code file:

    Code (CSharp):
    1. Quaternion spaceRot = Quaternion.Euler(90 - World.Latitude, 0, 0) * Quaternion.Euler(0, World.Longitude, 0) * Quaternion.Euler(0, lst_rad * Mathf.Rad2Deg, 0);
    And replace it with this line:

    Code (CSharp):
    1. Quaternion spaceRot = Quaternion.Euler(90 - World.Latitude, 0, 0) * Quaternion.Euler(0, 180 + lst_rad * Mathf.Rad2Deg, 0);
    Let me know if you run into any further issues!
     
    hopeful likes this.
  4. neXib

    neXib

    Joined:
    Aug 22, 2017
    Posts:
    6
    Hi. I love TOD so far, but I am like someone else in this thread trying to apply a night sky to my scene. It's working quite well, I can see it change and move realistically with lat, long and time.

    My issue is that I want the initial position to be different, and I can't seem to figure out how (apart from changing the source file but that's not quite doing it either). I'm not as used to Unity as other 3D applications, is there any way to offset/or move the starting position of the texture on the Space part of the sky? I'm using a lat long cube texture now.
     
  5. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    The date, longitude and latitude will specify the "start" position. Is it an option for you to just use a different start date or a different location?
     
  6. neXib

    neXib

    Joined:
    Aug 22, 2017
    Posts:
    6
    Not really as I am not going for style, I am trying to approximate reality. Not totally 1:1 but I would like the Milky Way core to be about where it is, because I can see that the approximate positions otherwise move fairly realistically with your plugin. (you can change time, lat long etc. in my app)

    I am used to Maya where I would just shift the mapping about a bit to have it start in another position. Would I actually have to hack about in the shader to fix this? I think offsetting latitude a bit might work for my case, but would have to double check that of course.
     
  7. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    So you're comparing the result in Unity to some sort of reference image for a certain location and time? if this is the case and you're observing a slight offset, please make sure to apply the spaceRot fix I posted above since it affects both the space object and the stars.
     
  8. neXib

    neXib

    Joined:
    Aug 22, 2017
    Posts:
    6
    Yes, I have some locations and times I'm checking with from photos, I'm also crosschecking with Stellarium and just sky coordinates. But I don't need to be super exact just close enough. I saw that code you posted, I'll check it again later today and see if I can make it work. Thanks
     
  9. Danua

    Danua

    Joined:
    Feb 20, 2015
    Posts:
    195
    Hello, does your asset support unity 2017.3?
     
  10. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    Sorry for the late reply, for some reason I haven't gotten an email notification for your post. Yes, it works with all current 2017 releases and even the 2018 betas.
     
  11. Iucounu

    Iucounu

    Joined:
    Oct 24, 2017
    Posts:
    19
    @plzdiekthxbye:
    I apologize if this was answered already (didn't read all 36 pages), but is development of this asset finished, or there will be more features implemented in the future?
     
  12. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    This depends on the feature requests I receive. If a request for a new feature is sent my way and I feel like it makes sense to add it for everyone then I'm adding it. One area I'd like to work on at some point are fully volumetric clouds, but I cannot give an ETA on those so don't buy the package with the intention of waiting for those.

    For the atmosphere itself and the stars there's simply not all that much left that could be done. Some people have requested the option to blend in a custom sky or space cubemap at day. Another one that's occasionally mentioned is aurora borealis support. If you feel like something is missing just let me know.
     
  13. Maryclover

    Maryclover

    Joined:
    Oct 3, 2017
    Posts:
    10
    Hi, I am trying to make a game that user stair into the sky for a long time with SteamVR. I find banding very noticeable and distracting. I am uploading a screen shot but may not be as visible or as pronounced in the image. Do you have any suggestion how to reduce it?
    Thanks!
     

    Attached Files:

  14. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    By default Time of Day should output dithered color (check the "Color Output" property on the TOD_Sky component) which takes care of this. You either have this disabled or a post process effect reintroduces banding.
     
  15. MattMurphy

    MattMurphy

    Joined:
    Dec 24, 2013
    Posts:
    111
    @plzdiekthxbye could you provide more details on how to allow other shaders (transparent) to include AtmosphericScatting calc to effect they're appearance? There's a very small section in the PDF about it but it doesn't really explain how to use it.
     
  16. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    First, include the Time of Day files in your custom shader:
    Code (CSharp):
    1. #include "Assets/Time of Day/Assets/Shaders/TOD_Base.cginc"
    2. #include "Assets/Time of Day/Assets/Shaders/TOD_Scattering.cginc"
    Then in the vertex shader add something like this:
    Code (CSharp):
    1. // v is the vertex shader input, o is the output
    2. float4 projPos = ComputeScreenPos(o.vertex);
    3. float3 screenPos = projPos.xyz / projPos.w;
    4. float4 worldPos = mul(unity_ObjectToWorld, v.vertex);
    5. float depth = saturate(Linear01Depth(screenPos.z));
    6.  
    7. // Write the result to a variable in the v2f struct so we can access it in the fragment shader
    8. o.scattering = AtmosphericScattering(ScreenToFrustumRay(screenPos.xy), worldPos, depth);
    And in the fragment shader adjust the final color like this:
    Code (CSharp):
    1. // i is the fragment shader input, color is the result
    2. color.rgb = lerp(color.rgb, i.scattering.rgb, i.scattering.a);
     
    hopeful and MattMurphy like this.
  17. Nadan

    Nadan

    Joined:
    Jan 20, 2013
    Posts:
    341
    Hi,

    I have added Chronos ( https://ludiq.io/chronos ) to my game so I can stop, fast forward and rewind time. Now I need to sync the Time of Day Dynamic Sky Dome to Chronos somehow.

    What variable could I access to make the time go backwards? I think I could stop the time by setting Wind Speed to 0 (TOD_Animation) and make the Progress Time boolean false (TOD_Time). But I wonder if there is some other way to make the time (sky etc.) stop and how to go backwards? I noticed I can't set the Wind Speed to negative.
     
  18. Maryclover

    Maryclover

    Joined:
    Oct 3, 2017
    Posts:
    10
    Thanks for the reply! I created a new project and made sure everything is default. I added TOD prefab and TOD_camera on camera and looked up at the hour 0.5. The attached picture is what I see. I made sure that the color output is dithered. Is this expected? banding2.PNG
     
  19. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    If you want more granular control over time progression I'd recommend disabling "Progress Time" and indeed adding / subtracting time yourself. You can do this while taking the time curve set on TOD_Time into account using the "AddHours" and "AddSeconds" methods on TOD_Time (TOD_Sky.Components.Time). Negative values should turn back time.

    The animation is a bit more problematic unfortunately if you want to turn back time as well. For now you'll have to copy the code from TOD_Animation.Update and use your own deltaTime, but I'll make sure to add a nicer API call similar to TOD_Time in the next update.

    Sorry, this is totally a F***up on my end - it only works when you add "TOD_Scattering" to your camera s well. Let me know if you can't use TOD_Scattering in your project and I'll post a workaround here. The code that sets the required texture is this:

    Code (CSharp):
    1. Shader.SetGlobalTexture("TOD_BayerTexture", DitheringTexture);
    Where DitheringTexture is Time of Day/Assets/Textures/bayer_matrix.
     
  20. MFKJ

    MFKJ

    Joined:
    May 13, 2015
    Posts:
    245
    I am getting jittery cloud/sky when i change my environment, camera including the skybox position near the origin as my scene is very large .
    Have you added that toggle as you mentioned in the post ? I update like this
    Code (CSharp):
    1. public Vector3 OffsetUV
    2.     {
    3.         get
    4.         {
    5.             var pos = transform.position * 1e-4f;
    6.             var rot = Quaternion.Euler(0, -transform.rotation.eulerAngles.y, 0);
    7.             return Vector3.zero;//rot * pos;
    8.         }
    9.     }
    And it is working fine but i am unable to understand it purpose
     
    Last edited: Apr 12, 2018
  21. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    Yes, set "Camera Movement" on TOD_Animation to 0 and camera movement will no longer affect cloud movement.
     
  22. Maryclover

    Maryclover

    Joined:
    Oct 3, 2017
    Posts:
    10
    Thanks so much! It worked and looks amazing :)
     
  23. AkinBilgic

    AkinBilgic

    Joined:
    Jun 14, 2016
    Posts:
    7
    Thanks for fixing the orientation of the stars!

    If I could make one request to improve the night sky further (and hopefully shouldn't be too difficult to implement):
    Right now, from my understanding the stars are generated from a list (stars.txt) that only specifies Coordinates and Intensity. But there could also be color temperature of each star so you'll get a much more realistic result with stars shifting into the blues and reds as they do on a clear night sky.

    Here's a spreadsheet with those star values I put together if it helps:
    https://docs.google.com/spreadsheets/d/1IhnnO-S4W393VS5YUywwGV-dzCokJ3ioQIQ0XQxHmZI/edit?usp=sharing

    Then maybe add a 'twinkle' parameter to simulate atmospheric distortion of the starlight, and now we've got a super realistic night sky!
     
    Last edited: Apr 16, 2018
    antoripa, hopeful and mons00n like this.
  24. Peacewise

    Peacewise

    Joined:
    Feb 27, 2014
    Posts:
    49
    Hello, I have found that when I have Unity's post processing stack enabled, TOD_Rays do not appear. Simply disabling the post processing stack makes the rays visible again. How would I make them work together?
     
  25. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    That's a great idea. What sources did you use to create that spreadsheet?

    I'm checking with some people who are using the post processing stack together with Time of Day and will report back when I know more.

    EDIT: What's your component order on the camera? It seems to be working with TOD_Rays before the post process layer:

    2018-04-24-DefenselessRodent-27700.jpg
     
    Last edited: Apr 24, 2018
    Salvador-Romero and hopeful like this.
  26. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    581
    I'm testing the Unity 2018.2.0b2 and TOD seems to work fine despite multiple exceptions in the console:

    I hope you could review it soon :)
     
  27. jessejarvis

    jessejarvis

    Joined:
    Aug 9, 2013
    Posts:
    287
    Is this known to work with Vegetation Studio?

    TOD_Scattering seems to be glitchy:



    Edit: TOD_Shadows had a little bit of an issue as well showing the horizon line, but putting Fade up to 0.074 seems to have blended it enough not to notice.
     
    Last edited: Apr 29, 2018
  28. AkinBilgic

    AkinBilgic

    Joined:
    Jun 14, 2016
    Posts:
    7
    The data in the spreadsheet came from the HYG star catalogs available here: http://www.astronexus.com/hyg

    I only kept the stars up to a magnitude of 7, converted right-ascension to longitudinal degrees, and ran the star's Color Index values through a formula to get the Color Temperature values.
     
    mcmorry likes this.
  29. visualjump3d

    visualjump3d

    Joined:
    Jun 6, 2014
    Posts:
    9
    I received this error with the new unity beta:

    allowed to be called during serialization, call it from Awake or Start instead. Called from MonoBehaviour 'TOD_Sky' on game object 'Sky Dome'.
    See "Script Serialization" page in the Unity Manual for further details.
    TOD_NightParameters..ctor () (at Assets/Time of Day/Assets/Scripts/TOD_Parameters.cs:343)

    how can I do ?
    Thank you .
     
  30. 3DSim

    3DSim

    Joined:
    Sep 5, 2012
    Posts:
    3
    I have been working on a project in unity Unity 5.6.5f1 (64-bit). I wanted to use the Time Progression Script to advance the TOD while over time, but the sky color is not chaning, The ambient light changes, but the sky remains bright throughout the sequence. I am progressing the time at 1min intervals and have tried 5, 10 and 30 but the sky is too bright at 0hrs so the effect of the sun rising is not being seen.
     
  31. cwxxc3

    cwxxc3

    Joined:
    Feb 1, 2017
    Posts:
    23
    Is there a way to render all the stars in the camera? When my player is high enough on the map only the top half of the dome renders with stars. I would like the whole dome to render instead
     
  32. MaciejZi

    MaciejZi

    Joined:
    May 19, 2014
    Posts:
    5
    Hello,

    Does anyone have any idea how to get rid of jumping effect of TOD_Rays like shown in the video linked below? This does not look nice.

    https://i.imgur.com/e9rcEuI.mp4

    Thanks for any tips,
    Maciej
     
  33. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,191
    Possibly that jitter relates to the trees? In a different view without the trees, do you get the same jitter?
     
  34. MaciejZi

    MaciejZi

    Joined:
    May 19, 2014
    Posts:
    5
    Yes, that is definitely caused by the trees. But removing the trees is not the solution I am looking for :D
     
  35. sapster

    sapster

    Joined:
    Jan 23, 2017
    Posts:
    2
    Is this asset still being supported? It hasn't been updated in over a year and the demo link is dead.
     
  36. Maryclover

    Maryclover

    Joined:
    Oct 3, 2017
    Posts:
    10
    Hi! I am trying to transition TOD to a different fantasy sky in-game and then back to TOD. Is there a way to slowly fade out everything including light, disable TOD completely, and then fade TOD back in? Thanks! :)
     
  37. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    I'm hoping for changes on Unity's end before this leaves the Beta. Will update accordingly should they actually stick to it in the final release. The sky dome should still work perfectly fine, but I understand that it's frustrating to get spammed with the messages in the console. The workaround would suck pretty hard though, so I'd definitely prefer if they come to their senses before the final release.

    I don't totally understand what you're describing. Is it working with the normal automatic progression and just not when you manually set it?

    You can try increasing the "resolution" parameter on the TOD_Rays script and see if it's caused by that. Also check if disabling time progression solves it -- in this case it would be caused by the movement of the sun and you can eliminate it by increasing "Light -> Update Interval" on TOD_Sky.

    I've updated the demo to WebGL: http://modmonkeys.net/dat/pub/timeofday/

    EDIT: Demo link on the Asset Store is also working again.

    How are you rendering the "fantasy sky" in your scene? It should probably render on top of Time of Day and occlude it that way?
     
    hopeful likes this.
  38. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,198
    For an architecture shadow simulation a change the time and the month of the plugin with a slider.
    My question is, do I have to runtime-adjust the UTC-Value by script for the summer month in Germany (Winter +1, Summer +2)?
     
  39. philc_uk

    philc_uk

    Joined:
    Jun 17, 2015
    Posts:
    86
    Hi
    For a standard outside environment, using the default skydome prefab as-is, with the time moving forward ect, with just the single directional light
    - What are the recommended Unity Lighting settings?
    (Realtime lighting, mixed lighting, intensity multipler, Auto Generate ect)??

    Thanks!
     
    Last edited: Jun 28, 2018
  40. gambr

    gambr

    Joined:
    Oct 13, 2017
    Posts:
    103
    Hi plzdiekthxbye,
    I don't want to talk about why developers use the singleton pattern, and I don't want to know why TOD_Sky is implemented in that unusual way (a singleton with a list of instances). But why during Unity player startup (from Awake to Update), there are two "Cleanup" and two "Initialize" calls? An overall of three instances created, considering at the first Cleanup call an instance is already present.

    The problem is that I want to set some values (i.e. TOD_Sky.Instance.Clouds.Coverage) on Awake() of my Main MonoBehaviour but at that point TOD_Sky.Instance is null. Moreover, what if I set the cloud coverage value to one of the created/deleted instances from Awake to Update? I expect that value will be lost. Would it be an expected behaviour?

    Regards,
    Gianni
     
  41. gambr

    gambr

    Joined:
    Oct 13, 2017
    Posts:
    103
    Oh my God, and why the TOD_Sky.Instance is destroyed ("Cleanup" called) before OnDestry() and "Initialize" is then called again?

    I have to serilize data. Where should I get a valid TOD_Sky.Instance on application closing?
     
  42. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    I already replied to your email, but to repeat it here for everyone: The time you set in Time of Day has to fit the UTC parameter. So if the time jumps forward by one hour due to summer time, the UTC parameter also has to be updated at the same time.

    Depends on your scene, but I've never managed to get decent results that weren't performing like ass with Unity's GI. I think it's mostly supposed to be used with static lighting conditions, with dynamic scenes at most using a reflection probe. It could work for small scenes though, but you'll have to experiment yourself.

    Initialize does not create any instances and is only called once. The sky dome uninitializes when you deactivate the game object and then re-initializes when you re-enable it.

    You cannot make assumptions for the execution order of Awake / OnEnable calls across different scripts unless you specifically specify the execution order in the project settings. I don't recommend doing that, it's a much better idea to have a custom initialization manager that instantiates / enables / loads all other game objects and scenes.

    EDIT: For the sake of completeness, in small projects it can be an option to work with references to other game objects in the Start method, but it's still terrible. If you don't like the singleton pattern don't use it and just instantiate the sky dome in your own script and store the reference there as well. It will be guaranteed to be initialized after the GameObject.Instantiate call.

    Again, no matter where cleanup is called, you cannot make assumptions that script A will call OnDestroy before script B or vice versa unless you explicitly set it up in the project settings, which is still a terrible idea. Saving should be done before you call Application.Quit altogether.
     
  43. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    FYI I was asked to change my name on here as the old one was violating the community guidelines. So here I am, the artist formerly known as plzdiekthxbye. Have fun mistyping this one.
     
    hopeful likes this.
  44. mostlyhuman

    mostlyhuman

    Joined:
    Mar 16, 2013
    Posts:
    53
    When TOD is in nighttime all of my materials get really glossy creating an almost wet look, is this something TOD is doing and if so how can I tweak that?
     
  45. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    681
    Can you screenshot this for me? It doesn't sound normal. Are you using the standard shader on the objects that are affected? What's your nighttime light intensity set to? Do you have the reflection mode on Time of Day set to cubemap?
     
  46. PetraCephas

    PetraCephas

    Joined:
    Mar 27, 2014
    Posts:
    6
    Long time user. Love TOD. Best ever! I have been trying to use TOD in my latest project using 2018.2 HDRP. Having some issues. Does TOD support HDRP and if so are there any special steps that need to be taken to set it up? (I did google this and read the last 5 pages of this forum posts and could not find the answer myself.)
     
  47. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,198
    Right, is LDRP / HDRP supported?
    Don´t see TOD-Sky at all using Unity 2018.2.0 and HDRP.
     
    Last edited: Aug 1, 2018
  48. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,191
    Unity's HDRP is still under development and not expected to be complete till early 2019. Very few plugin makers are going to try to support it before the specs are finished.
     
  49. sean_virtualmarine

    sean_virtualmarine

    Joined:
    Dec 1, 2017
    Posts:
    4
    Hey guys,

    Has anyone solved the problem of your screen going black because NaNs are being generated when you look straight down?

    I've tracked this back to TOD_Scattering.cginc :: ScatteringCoefficients :: dir = normalize(float3(dir.x, max(0, dir.y), dir.z));
    Normalizing a 0 length vector.

    I can band-aid in a fix, but I'm asking here in case there's a known solution that I missed.

    Thanks,

    Sean
     
  50. Oginecka

    Oginecka

    Joined:
    Sep 25, 2016
    Posts:
    7
    I am having the same issue. The whole camera is black when built in a stand-alone client.
    Could you give me advice on how to avoid this?
     
unityunity