Search Unity

2D Sky [Released] - A Dynamic Procedure Sky System for 2D and 2.5D Games

Discussion in 'Assets and Asset Store' started by chronos78, Apr 25, 2013.

  1. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    I'm happy to announce that 2D Sky has been accepted and is now available on the Asset Store.

    Get it Here


    Features:
    • Requires 1 draw call (2 if stars are used)
    • Day / night cycles
    • Animated cloud formation
    • Adjustable fake painterly style
    • Optional stars at night (requires 2nd draw call)
    • Basic weather simulation included
    • Weather simulations are easily customizable with C#
    • Supports both Unity Free Pro
    • Works on iOS (untested with Android or Flash)
    • Incredibly small resource footprint ~40KB

    [video=youtube_share;clzV9nueZ_s]http://youtu.be/clzV9nueZ_s​
     
    Last edited: Jul 11, 2013
  2. Burletech

    Burletech

    Joined:
    Jul 1, 2010
    Posts:
    73
    This looks really good. Can textures be changed at all (Like the star textures)?

    Edit: Never mind. I just purchased this product and the answer is yes, you can change the texture. I have to say I'm very pleased with it so far. Great job on a very useful asset.
     
    Last edited: Apr 26, 2013
  3. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Thank you for your purchase and I'm glad you are finding the asset useful.

    As you found out you can indeed modify the textures. In the next update you will also have the ability to change the size of the sky gradients texture up to 4096x512 to allow for even more detail to be painted into the sky and clouds.

    Another feature suggested by a user that may make its way into the next update is the ability to add fog layers with adjustable depths from the camera. I'll be playing with this idea over the weekend to see how well it works.

    Also in the works are several tutorial videos on how to setup and use this asset package. These videos will show how to use the weather simulation system and how you can write your own decorators for custom weather effects. As these videos become available they will be posted here.
     
  4. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    616
    Have you tested performance on mobile? Looks great and I could definitely use something like this if it runs well on a mobile device.

    Good work.
     
  5. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Newer mobile devices can run with the full sky shader and there is a simplified shader included to use on older devices were performance is tight. With the simplified shader you sacrifice one layer of the cloud effect but the rest is the same. I've tested this package on iOS (iPhone 4, iPad gen 1, iPad gen 3) but not on Android or Flash since I do not have the capacity to do so. If someone could test it and let me know how well it works or not it would be greatly appreciated.
     
  6. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    As seems to always be the case real life interferes with the best laid plans. There is still a major update in the works (including multi-layered fog) as well as some tutorial videos but they've had to be set aside for a bit as some other issues have become more pressing. However a minor update has been submitted to correct an issue causing the sky to render magenta when using DirectX 11. I've also included some linear color space versions of textures for those of you working with that. I will post as soon as the update is posted to the store and again when the next major update is ready or the tutorial videos become available.

    The new version that fixes the DirectX 11 issue is now available on the asset store.
     
    Last edited: Jun 3, 2013
  7. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    Good tool. Is it possible to not attach the sky to the camera FoV and position/scale the sky plane yourself? Currently I'm just seeing a zoomed-in fraction of the sky in actual gameplay, which isn't super useful. I'd also greatly appreciate some more control over the colors and gradient used without having to muck around with the textures itself, if possible.

    Edit: Nevermind, it seems you can position and scale the sky plane itself, although it can be kind of tricky to scale, since the highlighted box doesn't scale.
     
    Last edited: Jun 17, 2013
  8. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    In the next update I'll look at having the highlight box adjust with scale.
     
  9. Mars91

    Mars91

    Joined:
    Mar 6, 2012
    Posts:
    572
    News?
     
  10. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Currently out of town on vacation with the family. I'll be working on it when I get home next week and will hopefully have a new update submitted for review by the end of next week.
     
  11. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Finally got a chance to get back to work on this project after being out of town for awhile. Thanks for your patience while I was away.

    So what's new?

    First up is the way the gizmos for the planes are drawn. The underlining code has been completely redone so that they will now move, scale and rotate properly whether or not they are attached to a camera.

    Secondly, fog planes have been added.

    $2dSky_concept01.png

    This feature has been a long time in coming. With the new fog plane feature you will now be able to add multiple layers of fog. Each layer can be individually customized and positioned to get the look you are after. And just like the sky plane, each fog plane can be attached to a camera to fill the entire view area or you can scale and position the fog plane yourself for more flexibility. A word of caution, even though each fog plane only requires a single draw call because it is a fullscreen transparent effect it may negatively affect performance on mobile platforms.

    So when can you get it?

    There is still a bit more work to do before it gets submitted for review. I have to finish testing the new additions on the Mac and iOS platforms as well as update the documentation. If all goes well it will get submitted this weekend and be available soon after that.
     
  12. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    Looking great! Can't wait to try it out. Has it been submitted?

    Quick question, is there a recommended method for forcing wind/cloud direction for a more consistent wind?
     
    Last edited: Jul 21, 2013
  13. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Yes it was submitted the beginning last week and expect that it will be released any day now as long as nothing goes wrong in the review process.

    The recommended way to achieve this is by either modifying the existing cloud animation decorator [CloudAnimation.cs] or writing your own. The system was designed to be modular so that you could have complete control over how the sky and clouds behave using these decorator classes. You can use some or all of the ones included with the package or create your own to get exactly what you are looking for.

    If you take a look at the BasicWeatherSimulater.cs file (Yeah I know its spelled wrong, will fix it some day) you can see how the different decorators are stacked together to form a Sim that the sky uses to animate itself.

    And of course if you prefer not to use the decorator system for some reason you can always create your own. All the values needed to control the sky are made public from the Sky class found in the Sky.cs file. Just attach your system instead of the BasicWeatherSimulater component to the sky plane and you should be good to go.
     
  14. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Just got confirmation that the new update with multiple fog planes has just gone live.
     
  15. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    Hi Chronos78,

    I've noticed that the day length color animation persists even when a build is minimized and otherwise paused.

    So it can be morning, and then I minimize the build window (or the unity editor); and then when returning to the window,
    instead of it still being morning, it can be afternoon or even night; which can be pretty weird if everything else is still lit with morning in mind.

    Great asset, I'm using it quite a bit.
     
  16. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    The reason for that is the simple day / night cycle uses DateTime.Now to calculate elapsed times instead of relying on Time.time. Simply replacing the former for the later should allow the day / night cycles to pause like you would expect.
     
  17. BlueSin

    BlueSin

    Joined:
    Apr 26, 2013
    Posts:
    137
    Can't seem to set the time. Are we able to do that? I actually use your Sky as a main menu background in addition to inside my maps. But when a map is created or resumed I need to set the time either to the default, or to the time it was in their last save game. Yet when I set the time nothing happens. It just continues on from its current time.
     
  18. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    @chronos78:

    Is there a way to change the UV tiling of the fog planes?

    Instead of parenting it to the camera (it looks strange to have fog follow you around) I have a nice large plane that covers the entire area. However, changing the scale also changes the size of the fog clouds. Is there a way to modify the size of the panel without stretching out the textures?
     
  19. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    The fog layers can be parented or not depending on your application. As you found out, sometimes it just doesn't make sense to have them parented. Never needed them unparented myself so never thought about being able to adjust the texture tiling. It is possible to adjust the uv tiling but not without modifying the fog shader and the fog script. If you send me an email at info@cygengames.com I'll send you the modified scripts with the ability to tile the uvs.
     
  20. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    Thanks, will do!
     
  21. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    To celebrate 2D Sky's 1 year anniversary it has been placed on sale for 50% off.
     
  22. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    616
    Hopefully someone is still monitoring this assets forum. :)

    I've using 2d Sky in my latest game. Works great except for one thing.

    All is good running in the editor, but once I build and install on iOS the sky transitions are not always smooth. They tend to randomly shift instantly. The clouds will be in one location transitioning smoothly then all of a sudden they jump to a new location. They Sky plane itself doesn't jump, just the clouds on the plane.

    Again, this only happens once it is deployed to iOS. Does not happen when running in the editor.
     
  23. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Yup, still keeping track of things.

    From the description you provided it sounds like there is an inconsistency in frame rate and or your length of day is too short. The updating of the transitions is controlled by the amount of time elapsed. So whenever the sky simulation is update it looks at how long it has been since the last update to determine where in the transition it should be. What this means is if the time between the last update and the current update is greater than the step determined by the length of day the sim will skip steps to keep in time.

    Another possibility to check if only the clouds are jumping is that you've not adjusted your fixed timestep as 2D Sky works of FixedUpdate() as opposed to Update() to improve performance. It is also possible that your iOS build is slowing down to the maximum allowed timestep which is a 3rd of a second by default. If the clouds seem to be pulsing at about 3 frames a second then this is probably the case. If possible decrease the max timestep to match the fixed timestep optimally 0.01667 or 0.03333 for 60fps or 30fps respectively.

    Hope that helps get thing on track for you.
     
  24. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    616
    Hey Chronos78,

    Thanks for getting back to me. After a lot of build and deploys to iOS I think I've isolated the issue although I have not figured out a fix yet.

    It seems the cause of the "shifting-textures' is non-zero windspeed for Fog.

    In my setup, I have a single sky component and a single fog component. I use my own sky/fog manager to lerp between different sky/fog configurations.

    I have found that if the fog wind speed is non-zero, the issue will occur and if it is set to zero it will not occur.

    Remember this only happens after deploying to iOS, does not happen in editor and I have not tried on other devices. The sky wind speed does not cause this issue, only the fog wind speed.

    I also don't think this is related to my custom sky manager as I was able to reproduce the issue using the demo scene from your asset.

    For now, my workaround is to simply keep the fog wind speed at zero and only vary the other parameters.

    Would be great if you could figure out the cause of this. I love the asset and plan to use it in future projects. Really like how easy it was to write my own manager. Very nice API.

    -Jeff
     
  25. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    So if it is only happening in the fog and not the regular sky I think the problem may be isolated to the fog shader, most likely do to adding code to make the fog texture tilable. Give the following changes to CG_Fog.shader file a try and see if this fixes the problem. I'd test it myself but I currently do not have the ability to test on iOS devices.

    Change
    Code (csharp):
    1.  
    2. o.uv1.x = (o.uv1.x * 0.5 + _FogOffset) * _FogTilingX;
    3. o.uv1.y = (o.uv1.y * 0.98 + 0.1) * _FogTilingY;
    4. o.uv2 = float2(v.texcoord.y, v.texcoord.x);
    5. o.uv2.x = (o.uv2.x + _Time.x * _VerticalMotion) * _FogTilingY;
    6. o.uv2.y = (o.uv2.y * 0.98 + 0.1) * _FogTilingX;
    7.  
    To
    Code (csharp):
    1.  
    2. o.uv1.x = frac(o.uv1.x * _FogTilingX * 0.5 + _FogOffset);
    3. o.uv1.y = frac(o.uv1.y * _FogTilingY * 0.98 + 0.1);
    4. o.uv2 = float2(v.texcoord.y, v.texcoord.x);
    5. o.uv2.x = frac(o.uv2.x * _FogTilingY + _Time.x * _VerticalMotion);
    6. o.uv2.y = frac(o.uv2.y * _FogTilingX * 0.98 + 0.1);
    7.  
    Let me know if this made any difference or just blew stuff up.

    Later
     
  26. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    616
    Ok, I'll test this sometime next week as I'll be on vacation until then.

    Thanks!
     
  27. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    616
    He Chronos,

    So I've go your cloud system working great in my mobile game. Love how it looks and works...

    However, I have a huge performance problem when running on an iPad 3. I even switch over to use the "Simple Shader"

    I even switched over to your demo that comes with the package and ran that on the iPad 3 with simple shader. It gets about 20 fps tops.

    Is there anything I can do to get better perf on this device ?
     
  28. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    There are two things that will greatly affect the FPS you are getting. The first is to lower how often the sky gradient is updated. This is a big deal where the demo is concerned since a whole day / night cycle is only about 2 minutes long. Which means that the gradient is calculated a whole lot. So to correct this simply make the day / night cycle take more time. The second and more likely fix is to lower the mesh density of the sky. Too many segments in the mesh will adversely effect the frame rate on a mobile device. So lower the number of segments down to the point where you are getting acceptable frame rates again.

    Hopefully this gets your iPad3 frame rates back up to where you need them.
     
  29. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    616
    Thanks for the quick response.

    I've done some experimenting and unfortunately the perf. issue seem to be with the shader.

    In you demo, I set the width and height segments of the sky to 4 and 2 respectively. I also completely disabled the basic weather simulator component to no time would pass.

    I still get 20 fps. The thing is, this is only this slow on the iPad3. Even the iPad2 is quicker. I assume this is due to the higher resolution of the iPad3.

    So my question is this. Is it possible to speed up the Simple Shader in some way? Is it the texture reads that are possibly slowing things down?

    I don't require a full day night cycle. My game starts with a blue sky, then every 10 to 15 seconds I make the sky a bit more stormy looking manipulating the Sky component and single fog plane directly with my own "sky manager" (I have my own blue to gray sky gradient texture.)

    Ideas?
     
  30. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    From the sounds of it you might indeed be GPU bound on the iPad3. To be sure you will have to to profile what is happening from inside of XCode. According to Unity's site the iPad3 should still be able to render full screen effects just fine, http://docs.unity3d.com/Manual/iphone-Hardware.html. So without having the ability to test on an iPad 3 I can only guess what might be going wrong.

    As for improving the simple shader there isn't much more that can be done to it as it has already been optimized to the point of only using a single texture lookup.

    If you are GPU bound the only other thing that I can think of off the top of my head would be to render the sky to a render target at a lower resolution and the layer another camera that displays you game over the top of that.
     
  31. yty

    yty

    Joined:
    Aug 10, 2009
    Posts:
    82
    Can I add 2d sun and moon?
    And support the simultaneous emergence of multiple sun or moon?
     
  32. yty

    yty

    Joined:
    Aug 10, 2009
    Posts:
    82
    @chronos78

    bug....There will be a slash.


    2dsky 1.2 + unity3d5.6.2f1

    win10 64.1 + nvdia gtx980
     

    Attached Files:

  33. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Have confirmed that the bug exists in the current version of 2D Sky on the Asset Store. Not sure what is going on since this version has been online for more than 9 months and hasn't been an issue until now. I've verified this seems to only happens with the high res (hr) versions of the sky textures and does not seem to be an issue with the lr versions. I'm going to look at my personal archives to see if the problem is isolated to the Asset Store version or maybe an update to Unity changed something that will require the sky shader be fixed. Once I know more I will post my findings here as well as upload a fixed version to the Asset Store.

    Thanks for bringing this to my attention. I'll try to get this resolved as fast as I can.