Search Unity

UniSky - real-time procedural sky tool - now available on the Asset Store

Discussion in 'Made With Unity' started by Chris Morris, Jan 7, 2011.

  1. dgutierrezpalma

    dgutierrezpalma

    Joined:
    Dec 22, 2009
    Posts:
    404
    Chris, I know it's an easy fix, but it would be nice being able to modify those values from the API...

    In addition, those values aren't even exposed as public properties of the class, so you are asking us to modify your code in order to make that functionality work. I know the changes aren't that complex, but my main concern is that, if I touch the code of your classes, it could become a maintenance nightmare because I would have to merge manually my changes with your changes whenever you release a new version of UniSky.

    For that reason (and taking into account that it's a quick fix), I'm asking you to include those changes in the next release (if possible).
     
    Last edited: Jun 23, 2011
  2. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    That's a good point - it's a quick addition, so I just added it to the v1.2.6 project. Thanks for the feedback :)
     
  3. Deleted User

    Deleted User

    Guest

    I don't know if anyone already talk about it, if so than i apologize but it would be a great thing if there would be a possibility to add more than one moon.
    It would be kinda use full for developers that work more in the fantasy part of the game where night sky dose not have to look like our natural.
    The possibility to add more than one moon and own night sky would be just great.

    This is an example of what i mean :

     
    Last edited by a moderator: Jun 23, 2011
  4. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    @thinker - that has been requested before, but I haven't had time to get around to it yet. This will be a feature in a future release
     
  5. Deleted User

    Deleted User

    Guest

    Well than thats great ! Sorry for repeating the same request i just wanted to make sure that it will be added.

    BTW. I cant really see the stars at night its just a solid black color or i am just finally blind at my age haha.
     
  6. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    @Thinker - Not a problem at all :) I wouldn't expect anyone to shuffle through every page of each thread.

    Hmm, I'm not sure at what version this changed, but the stars are tiled too much for that high of a resolution texture. To make the stars more noticeable you can either scale down the texture by going to "starstexture.png" and reducing the "max size" to something like 512 or 256. Or you can reduce the tiling in the vertex program of "atmosScat.shader". In it you can change:

    OUT.texCoord = i.texcoord * 70;

    To something more acceptable for a high resolution starfield:

    OUT.texCoord = i.texcoord * 10;

    I've actually changed this for the next update because it looks better with the included starfield texture. Hope this helps
     
  7. Deleted User

    Deleted User

    Guest

    Yes it help a lot now i can see stars without a problem.
    But if i may ask there is one other thing where can i turn on the soft shadows in the sun ?
    I was trying to find it in every script and it was not there plus i can change it in the play mode ( i must say it looks great than ) but it of course resets to standard settings when stop.
    Can you direct me to the place where i can turn the soft shadow on ? It would be great. :)
     
  8. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    @Thinker - Sure, this was added in v1.2.5. For soft shadows, you would call this from your script's instance of the API:

    uniSkyAPI.SetSunShadows(LightShadows.Soft);

    and for the moon:

    uniSkyAPI.SetMoonShadows(LightShadows.Soft);



    Edit: These methods are documented at the top of the API's script and on our website - http://www.sixtimesnothing.com/unisky
     
    Last edited: Jun 27, 2011
  9. dgutierrezpalma

    dgutierrezpalma

    Joined:
    Dec 22, 2009
    Posts:
    404
    Thanks Chris. UniSky is a great product and I really appreciate that you listen the feedback from your customers :)

    I have another suggestion that (even if I won't use it for my current project) would be a nice addition for a future release: if/when you add support for several moons, try to add support for several suns (even if only one of them cast a directional light, it would be nice being able to see two suns on the sky).
     
    Last edited: Jun 27, 2011
  10. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    @david - Thanks for the kind words, I really try to give a lot of attention to the users.

    Regarding the multiple suns: Adding support for multiple moons isn't very difficult, as these are just billboarded sprites, but having multiple suns is different. The sun is actually calculated in the atmospheric scattering equation (which is based on realistic values and assumptions), and so trying to add multiple suns would not only require some serious changes to the shader, but it would also create some really buggy skies unless I got all the math JUST right. I might have a go at this if I can find the time, but I can't guarantee this will be implemented. Sorry! :)
     
  11. U2

    U2

    Joined:
    Aug 12, 2008
    Posts:
    216
    lol you know now that you mention it like that it makes me wonder if anyone has actually tried building a realistic model to simulate multiple suns. I mean really, it's not like anyone had ever seen a planet surface under those conditions. Usually you just see them in movies and earlier games that did not take real time shadows, clouds etc.. into account. They were usually just a cool looking static skybox and the rest is it's own thing. An interesting topic of discussion when you start to think about it.
     
  12. Johnxyz

    Johnxyz

    Joined:
    Sep 19, 2010
    Posts:
    9
    Can you please show me how to implement this to the script ? It would help me alot :).
     
  13. dgutierrezpalma

    dgutierrezpalma

    Joined:
    Dec 22, 2009
    Posts:
    404
    I didn't know it would be so difficult to add multiple suns, I only thought that if adding several moons would be cool, adding several suns would look really awesome. In any case, i wouldn't have any use for that feature in my current project, it was only a "cool idea".
     
  14. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    hehe it definitely is a cool idea - I imagine the light scattering in the sky would create some really cool effects.

    @Johnxyz - In the example project, looking at "ExampleScript.js/cs" will give you a basic understanding of how to call the API functions. The shadows, in the exact context of the example script, is enabled with this line, :

    uniSky.SetSunShadows(LightShadows.Soft);

    The video tutorial is also a good starting point, as I explain the purpose of each line of code in the example script - http://www.youtube.com/watch?v=eG7Bmv2pjlM

    If you need any help further than this, just drop me an e-mail or PM and I'll be happy to explain further.
     
  15. ZachGriffin

    ZachGriffin

    Joined:
    Apr 1, 2010
    Posts:
    49
    Chris, I have a minor optimization request for you:

    In your scripts where you set the shader params in the update using something like .SetFloat("someString", 1.0f), could you use const strings to avoid declaring a new one each frame and tripping the GC?
     
  16. psyche

    psyche

    Joined:
    May 9, 2011
    Posts:
    10
    @Chris

    First of all congratulation for your great product.
    I would like to change the time of the day using a slider into my game.
    How can it be possible? // I think by using the same slider that the one that control the time in the GUI but I'm not able to locate it into the unisky script.

    Thanks.
     
  17. psyche

    psyche

    Joined:
    May 9, 2011
    Posts:
    10
  18. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    @ZachGriffin - That's a good point - thanks for the feedback. I was planning on an update down the road that focuses on all sorts of optimizations - there are many more I could do, but I've been focusing on just getting in functionality first, and optimizing later.

    @psyche - For your first question: The time can be adjusted through the API using SetTime(float) so you just need to hook up a GUI field to that value - something like a horizontal slider (http://unity3d.com/support/documentation/ScriptReference/GUI.HorizontalSlider.html)

    For your second question - are you using the latest version of UniSky? A shadow bug was fixed a couple of version ago. Also, to change things like bias, strength etc. you just need to get access to the sun in the script (C#):

    Light sunLight = GameObject.Find("Sun").GetComponent(typeof(Light)) as Light;

    Then you can change all these values with your instance of the sun.
     
  19. psyche

    psyche

    Joined:
    May 9, 2011
    Posts:
    10
    @ Chris- Thanks for your answer. A lot of time spent on this one but finally I figured out. Its seems to happen when the objects clouds and sky in cloud handler and sky handler are marked for receiving shadows. Unmarked them and all is fine again.
     
  20. avedis777

    avedis777

    Joined:
    Jul 10, 2011
    Posts:
    25
    Hi, This is my first post as I am currently running Unity Pro trial and plan to purchase it before it expires. This weather system looks really great! I read that the clouds are generated procedurally...Is it possible to edit the algorithm or to change how the procedural clouds look? I would like to be able to have different cloud types, is this a possibility or are there plans to have options?

    Thanks - nice work!

    Luke
     
  21. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    @avedis777 - It's all open-source, so you can mess with the procedural shaders any way you want. With the built-in parameters you can get a couple of different clouds types, so it's worth playing around with those first, and if you need something more specific you can turn to the shaders.
     
  22. avedis777

    avedis777

    Joined:
    Jul 10, 2011
    Posts:
    25
    Great, sounds like fun. Can't wait to play around with it! :)
     
  23. tomnullpointer

    tomnullpointer

    Joined:
    Sep 20, 2010
    Posts:
    142
    Hi Chris,

    Great work with this package. Ive a few questions though.

    Is there a way to alter the horizon color? BY this i mean the color that the skyhemisphere mesh is at its lowest edge (rayleigh etc alter the acual 'core' ). If I understand it right, this edge color changes per time of day etc (is it using the fog color?). My problem is that I want distant objects in teh scene to 'fade' into the skybox. This should be possible if the cloud layer is high enough and the horizon color of the skymesh matches the fogged out color of a distant object. Otherwise I get ugly silhouettes until they pop in or out.

    Is there a way to tint the overall sky color? So i could have an alien pink tint to th esky that will still work with the day/night cycle etc?

    Any suggestions?


    Thanks
     
  24. RichBosworth

    RichBosworth

    Joined:
    May 26, 2009
    Posts:
    325
    Hi,

    Can you possibly tell me the best way to use baked Lightmaps with UniSky? I don't plan on manipulating the time at all, and am really just using UniSky for dynamic clouds.

    Thanks in advance,
    Rich
     
  25. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    @tomnullpointer - unfortunately there are no controls to manipulate the sky scattering to an artificial color like pink. However the shader is open for modification if youre up for it. If not, you can send me an email and I'll put something together for you.

    @rickybozzy - one way is to run UniSky at your static time of day and take note of the suns rotation. Then set up lightmaps according to a directional light with that rotation.
     
  26. divinity

    divinity

    Joined:
    May 30, 2011
    Posts:
    411
    May I ask something? I love this prefab, but if there is a way please tell me, I want the night time to have a similar effect to the storm, with all the fog and the fact it is hard to see? as when it is night time, I can still see everything quite easily, and the terrain is still rather bright :O Please tell me if there is a way :D I love this prefab :D
     
  27. UnleadedGames

    UnleadedGames

    Joined:
    Feb 17, 2008
    Posts:
    242
    I have to agree with Divinity, this plug in is amazing up until the sun goes down, then it just is lacking that something that makes the night time click. The darkness from the fog would be a perfect step in the right direction for a solution.
     
  28. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    Thanks for the feedback guys - I should add this to the API, but you can achieve a night like you are describing with a couple extra lines of code:

    In C#:

    GameObject.Find("Moon").light.intensity = x;
    RenderSettings.fogDensity = y;


    That will give you a very dark night, with more extensive fog, depending on what you choose for x and y.

    Hope this helps!
     
    Last edited: Aug 1, 2011
  29. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    Oh, and don't forget the API function to set the ambient light if you want it really dark:

    SetAmbientLighting(Color ambientLevel);
     
  30. divinity

    divinity

    Joined:
    May 30, 2011
    Posts:
    411
    so what scripts do I edit? (I am a poor scripter lmao)
     
  31. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    If you're using the latest version of UniSky (1.2.6) you can add those lines in the same script that you control UniSky with (in the included example project it's "ExampleScript.cs/js").

    If you still need some help, just e-mail me and I'll be happy to work with you to get UniSky looking the way you want it in your project. (chris AT sixtimesnothing DOT com)
     
  32. amichaels

    amichaels

    Joined:
    Dec 14, 2009
    Posts:
    2
    Hi, great work with Unisky. We've bought the license, and are having a good time with it.

    Last week, we ran into a caveat that we can't seem to resolve. We're rendering rather large terrains (e.g. 16km square), where the edges of the terrain are often lower than the center. As a result, the shallow skydome implementation of Unisky is showing it's edge, and we can now see the blackness beyond. We've tried for several hours to adjust this skydome to make it hide the seam, but whatever logic you have to shade this dome is cutting off at what it thinks the horizon is, so we're spinning our wheels now.

    We tried the following things:
    1. Scaling the Inverted Skydome mesh in Y direction, to make it taller.
    2. Lowering the Mesh Altitude -- but this failed, because the dome itself would cover the outskirts of higher mountains which then would poke-through the skydome mesh.
    3. Scaling Skydome mesh in XZ direction.
    4. Modifying all code in atmosScat.shader to see if I could make *anything* paint a pixel below it's "horizon level" (applied to the meshes that we stretched in Y direction to make them taller).

    So right now, we're still stuck with a black horizon. Note, that for smaller terrains with no low points along the edges, it works fine. But our main demo test case is showing the skydome edge. (see image)

     

    Attached Files:

  33. Bluestrike

    Bluestrike

    Joined:
    Sep 26, 2009
    Posts:
    256
    Is Unisky 1.2.6 on the assetstore?
    Still mine is marked as up to date and contains 1.2.5
    will 1.2.6 remove the warning spam caused by the Unity 3.4 update?
     
  34. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,209
    I'm running UniSky 1.2.6.

    I created a new scene, and followed your "Quick Start" instructions within the readme:

    1) Created a Terrain.
    2) Main camera's "Clear Flags" set to "Solid Color".
    "Background" to solid black.
    "Far Clipping Plane" to 100,000.
    3) Drag the "UniSkyAPI" prefab, from inside the "Resources" folder, into your hierarchy.
    4) Use the UniSkyAPI GUI to assign UniSky your scene camera - in the "General" tab.
    5) Play the scene.

    I got nothing but a black sky and dark gray terrain. Fortunately I watched the video and apparently I needed to create an empty game object and dragged the ExampleScript into it and then it worked. As an artist and noob coder, I would have never figured that out without youtube. Even the written tutorial isn't very clear. It might be helpful to add that to the readme file within the package. :)

    I also asked a while back (before the weather update) about integrating sun shafts since Unity's didnt work with your sky system. Is there a way to turn those on?

    There are also a couple of sliders for the Weather Layers. I tried moving them in both my own project and your example project with little avail. What do they do? Is there an "artist friendly" way to use sliders to change the weather; darken clouds, add rain, etc?

    Thanks!
     
  35. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    @amichaels - I'll be responding to your email shortly. Scaling UniSky is possible, but it involves a few extra steps - I've done it for another UniSky user, so I will pass on to you the steps involved.

    @Bluestrike - UniSky 1.2.6 is on the Asset Store, so it's odd that it telling you you are up to date. The Asset Store is displaying 1.2.6 as the current version, so it must be a bug with the Asset Store.

    @adamzeliasz - I understand the shift from pure drag and drop to using an API involves a bit more of a learning curve for non-coders, but I felt it was necessary to give users full control of their scene. In this regard I tried my best to make it as easy to use as possible, so that even non coders could still understand the single-line commands. I'll look into making the written tutorials easier to understand.

    As for the sun shafts, we've developed our own image effect for doing that with UniSky: http://www.youtube.com/watch?v=-iFOl_RZgMY - it isn't fully tested across a bunch of graphics cards, but it works with the few we've developed with. I can send you a copy if you'd like, just drop me an email.

    The sliders for cloud cover, precipitation etc. will only update in real time while you are in play mode. Otherwise, the settings you assign in editor mode won't be visible until you press play. I would suggest pressing play, creating the look you are after with the sliders, and then reassigning these values back into the sliders while in editor mode to save them. With just a litttttle bit of coding you can also test out different rain settings (check the example script) - just play with the numbers in the parameters to see what they do.

    Hope this helps! Remember you can always email me if you want more specific help, I tend to check that more often than the forums.
     
  36. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    I had posted before that Unisky had a big performance impact in our project, but that has mostly gone away with Unity 3.4 and Unisky 1.2.6. However, the Moon still has a significant impact--causes an 8-10 drop in fps. We don't actually need the moon--it's overcast and rainy throughout the game--and I don't get any errors if I simply disable it, but is there any reason that (or deleting the Moon GO) might cause a problem?
     
  37. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    @gecko - no, I can't think of any problems it would pose since it is a pretty standalone component of the tool. As long as you aren't getting errors from other scripts trying to reference it, it shouldn't be a problem.

    I'll have to look into why the moon gives that big of a performance drop though - it's only doing some simple transforms. Seems like a good place to optimize - thanks for the feedback.
     
  38. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    So I just bought it, but the sky is showing up black in the example scene. I'll reload it in a fresh project and give it another shot.

    edit: aww snap it works in a fresh project.
     
  39. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    Just a quick update to anyone wondering: Our team has been extremely busy recently, but I will be working diligently to finish the full feature set + mobile as soon as possible. So just know that even though there has been a delay, I will finish these features, I'm not abandoning them :D
     
  40. Bluestrike

    Bluestrike

    Joined:
    Sep 26, 2009
    Posts:
    256
    hmm I used this piece of code to disable the sun from casting light, so I could use my own directional light and bake shadows:

    Code (csharp):
    1.     if(GameObject.Find("UniSkyAPI"))
    2.     {
    3.         isUnisky    = true;
    4.         uniSky = GameObject.Find("UniSkyAPI").GetComponent("UniSkyAPI") as UniSkyAPI;
    5.    
    6.         // Initiate and create default UniSky
    7.         uniSky.InstantiateUniSky();
    8.         GameObject.Find("Moon").light.enabled = false;
    9.         GameObject.Find("Sun").light.enabled = false;      
    10.     }
    But it no longer works, you are somewhere forcing the sun light to be enabled in 1.2.6?
     
  41. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    @Bluestrike - yes, actually a few lines were added to the Update() function on UniSky.cs/js to enable/disable the sun and the moon at certain periods of time as an optimization (so that the moon is disabled during daytime, and sun is disabled at nighttime).

    You can override this just by commenting out these lines in that update function:

    if(TIME < 19 TIME > 6) {
    moonLight.enabled = false;
    sunLight.enabled = true;
    }

    else {
    moonLight.enabled = true;
    sunLight.enabled = false;
    }

    Then I think your code will have the expected effect
     
  42. Bluestrike

    Bluestrike

    Joined:
    Sep 26, 2009
    Posts:
    256
    That works fine, Thanks
     
  43. paul.harden

    paul.harden

    Joined:
    Aug 8, 2011
    Posts:
    5
    Hi chris, just a quick question: is it possible to change the apparent size of the sun?
    Thanks!
     
  44. x4000

    x4000

    Joined:
    Mar 17, 2010
    Posts:
    353
    Hi Chris,

    Just bought Unisky this morning and am really impressed. However, I do have one performance issue that I'm seeing on windows in the unity editor (have not tried it in standalone or the mac yet). Basically, I can run Unisky in the example scene or in a scene I set up, and by default it gets great performance -- it's taking about 1.4ms per frame on average, and that's including the general overhead of the entire frame. The differential from adding Uniky seems to be about 0.6ms per frame, thereabouts.

    Then whenever the camera has its rotation changed in the X axis beyond a certain level (say, to around 300, for instance), the performance plummets. Suddenly Unisky is taking over 18s per frame, and that's the differential on top of the normal frame render time. I've been poking around at this and it doesn't seem related to lighting, and it's definitely not having any more render calls or anything of that nature. It seems like maybe it's some sort of calculation issue in the transforms perhaps, but the profiler is not very helpful because it's giving me a "f < INT_MIN || f > INT_MAX" error on the first frame, inside the Unity GUI. Very odd. But from what little information the profiler is giving me, it looks like there might be something to do with Graphics.Blit, which would support this potentially being related to transforms in some manner. I normally use DrawMeshNow for my other stuff, so Graphics.Blit is a bit new to me to do much with. Most of my customers really like their system requirements nice and low, so I've done little with render textures until this game, heh.

    Any thoughts?
     
  45. x4000

    x4000

    Joined:
    Mar 17, 2010
    Posts:
    353
    Oh, one other thing I should have noted: I'm still using Unity 3.3, not Unity 3.4. There's a very bad crash bug in 3.4 relating to PlayOneShot on sounds, and without that fixed I can't go to 3.4.

    EDIT: Just tested this in Unity 3.4, which I also have on my machine for testing, and it does the same thing. So it's not version-specific.

    EDIT 2: Actually, in Unity 3.4 I'm seeing this even without the rotation, with no other changes. Very odd. In Unity 3.3 I don't see it without the rotation.

    Messing with the z axis of the camera also can cause it, as can reducing the clipping distance.
     
    Last edited: Aug 29, 2011
  46. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    Hey Chris, do you have any idea how the Lumion guys are achieving their clouds?

    http://vimeo.com/16534222

    They're not volumetric - they're baked in realtime to the sky texture, as are yours, but they have a really gorgeous look to them!
     
  47. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    @ paul.harden and @x4000 - I apologize for missing your replies, these forums move somewhat quick these days and I don't always have time to check them.

    @ paul.harden - sorry, there isn't a really good way of doing this as it is a result of the atmosphere calculations and not a directly editable variable.

    @x4000 - That is really odd, perhaps it is a driver issue? I'm running on Windows 7 and Unity 3.4, and I'm not getting this kind of performance issue at all in the example scene, at any rotation. Let me know if you discover anything about this and if I hear this from any other user I'll try to take a deeper look into it.

    @duke - From the animation it looks like it uses one of those cellular automata systems, with billboards (it is actually pseudo-volumetric). I'm looking into something like this for our game and if I ever develop it I will do a write up about it in our development blog.
     
  48. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    I've fiddled with the inspector sliders but can't seem to change the sky dome color--it's an odd brown, see attached. Any suggestions?
     

    Attached Files:

  49. MaliceA4Thought

    MaliceA4Thought

    Joined:
    Feb 25, 2011
    Posts:
    406
    HI Chris...

    okay I am doing something really odd... (I think) I have UniSky working fine on my server, and I have day, night, clouds everything working, almost.

    The sun traverses the sky, then comes night.. I have the stars.. but no moon.. and yet.. although I have no moon in the sky, I have the reflection of it in the water on land :)

    Any suggestions where to look?

    Regards

    Graham
     
  50. Paaske

    Paaske

    Joined:
    Feb 8, 2011
    Posts:
    4
    Hi Chris

    I am also experiencing some performance issues with UniSky 1.2.6. I have a relatively simple scene with a building and some terrain. On my laptop (Lenovo W500 with Windows 7 x64), this scene runs at between 90 and 110 fps (VSync disabled). When I enable UniSky, the framerate drops to around 20 fps (sometimes as low as 10). I have disabled shadows on the sun light so the decrease in framerate shouldn’t be caused be shadow generation. UniSky only seems to add 14 additional draw calls but still, the performance impact is quite substantial.

    /Kasper