Search Unity

uSkyPro – Precomputed Atmospheric Scattering [2.0 Beta]

Discussion in 'Works In Progress - Archive' started by Luckymouse, Sep 14, 2014.

  1. Migueljb

    Migueljb

    Joined:
    Feb 27, 2008
    Posts:
    553
    First off love Usky thanks for making this wonderful plugin. So simple but yet looks amazing.

    Im having a problem. How do I make the Usky Sun appear thru the Unity skybox like infront of it? So it would be ignoring the unity skybox. Is there some sort of layer in the code how the Sun appears thats why its behind the skybox?

    -Miguel
     
  2. Ravel

    Ravel

    Joined:
    Nov 21, 2010
    Posts:
    605
    Hey, sun rays are totally broken in the latest version, please fix this, that's the feature why I liked your product in the first place. They are inverted and offset :( Please fix it, because it's the feature that got me hooked in the first place.

    There are no console errors whatsoever, will update the editor to see if it's the editors fault instead.
     
  3. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    I noticed that the sun intensity has no effect on the actual sun object brightness in the uSky beta. This messes up image effects like bloom. Is it possible for the graphical representation of the sun to be effected by the uSky sun intensity?
     
  4. Ravel

    Ravel

    Joined:
    Nov 21, 2010
    Posts:
    605
    Here is an image of the scatter bug I hope gets fixed soon :
    usky bugsky.PNG

    An update to Unity Editor fixed this issue. Tho one critical issue remains, the scatter begins from the center of the world, meaning that whats left behind the center is not scattered at all.

    To clear things out, everything below zero/negative Z axis value is not casted to the scattering space. This needs to be fixed Otherwise this asset can only be used with terrain systems that do not self center. A notable workaround is to position every game object greater than negative Z value, but this is a rather hacky way and I'd prefer to get an update from the asset developer instead.
     
    Last edited: Aug 10, 2016
  5. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    Is it possible to change the north direction in the beta?
     
  6. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    7,785
    Is there any way for me to be able to purchase USkyPro 1.x? I'm starting one of my projects over in Unity 4 and could really use an atmospheric scattering solution.
     
  7. JBT27

    JBT27

    Joined:
    Jul 13, 2016
    Posts:
    197
    USky 1.x is included with the purchase - it was for me at least.
     
  8. JBT27

    JBT27

    Joined:
    Jul 13, 2016
    Posts:
    197
    I've been tweaking the sky colour, and fog density, trying to get the look I want between a distant terrain silhouette, the tone of the sky and the colour of the fog. I'll accept that it is likely me, but this seems like a difficult thing to achieve at the moment. I'd appreciate some insights into how to do this, but also ask if it's possible to have a fog colour control added too.
     
  9. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    @Luckymouse

    Is it possible to change the north direction in the beta?
     
  10. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    OMG! I just realised that I was stuck in new unity forum page, Even I keep refreshing the page over pass weeks that i never get any new question listed or notification at all. Sorry guys. It was horrible mistake by unity:mad:.

    I will answer all your question following here.
     
    Last edited: Aug 11, 2016
  11. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    First thanks for jbakirli that make the Clouds texture tutorial for uSky 1.0. However the up coming new clouds for uSkyPro will be completely procedural based.

    We have discussed it over the email, I believe you found out that turn on the "Auto" build option of the scene in lighting settings fixed your issues.

    I don't really understand your question here, because the uSky sun is inside the skybox shader and it appears always in front of the sky, do you mean you want to make a custom sun from a texture?

    The sun disk in uSkyPro is just a temporary, it will replace with more option like able to change the intensity, disable it and get better looking as the uSky 1.0 sun in coming future version.

    Thanks for point that out this issue. I didn't know why this happen because this code will only execute during start up to generate the stars mesh and should not affect the runtime performance. I will investigate it more about it.
     
  12. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    Your image show the atmospheric scattering was up side down. In the beginning I thought it was a bug, but later i found out it was an known issue of unity editor that occurs if you enabled anti-aliasing with image effects on Window platform. (Not sure if it fixed already in newer unity editor version.)

    Solution: Please disable the "Anti Aliasing" in Edit/Project Settings/Quality, and everything should work fine as normal.

    I don't know about the negative Z axis issue that you mentioned is related to the image you post? or it is a different problem. Please lets me know if you disable the "Anti Aliasing" after still get the problem with it.
     
    Last edited: Aug 11, 2016
  13. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    Now out of the box the positive Z-axis represents as North, do mean you want to use other axis to point it as North?
    At the moment the simple answer is no. I probably need to find a way to re-map the entire co-ordination. I don't have solution in head right now, I will add this as wish list for future.

    As JBT27 answered, you probably figured out the uSky 1.0 is already in the asset. As I know that it may not work for Unity 4. The current 1.0 version is optimised to work with sphere mesh skybox in Unity 5. Please lets me know if you need help for that I can send you the older skybox shader that work in Unity 4.
     
  14. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    I believe you want to blend the distant terrain silhouette in fog, right? or something like haziness or foggy effect. It has been requested before. Current beta version only do the basic linear z-depth calculation for scattering, it definitely will improve that in future.
     
    JBT27 likes this.
  15. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    I know many of you guys are waiting the new clouds system. Sorry that lately i have to deal with a lot of my personal issue with my family.
    The development of the new clouds and other new feature for uSkyPro is still working in progress. The new clouds system is more complicated then I thought. There are still a lot of issue need to be solve. As long as the it get mature enough, i will give you guys some update post here.
     
    JBT27 likes this.
  16. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    567
    Just for note, it related only to the 2.x beta, 1.x works absolutely fine!

    Also, the beta version has a strange bug with lighting. When lightmap recalculation set to auto in the lighting tab and I hit play, environment lighting resets and do not apply to the objects in the scene. Disabling automatic lightmap recalculation temporarily solves this issue.
     
    Last edited: Aug 11, 2016
    Luckymouse likes this.
  17. JBT27

    JBT27

    Joined:
    Jul 13, 2016
    Posts:
    197
    Yes, that's what I meant. It's usable right now and looks great, but looking forward to future additions and changes to this.
     
    Luckymouse likes this.
  18. JBT27

    JBT27

    Joined:
    Jul 13, 2016
    Posts:
    197
    I can't deny I'm gagging for a new version, but take your time and get it right. USky is so nice even now. Future versions will be great.
     
    Luckymouse likes this.
  19. Ravel

    Ravel

    Joined:
    Nov 21, 2010
    Posts:
    605
    The negative Z axis issue, to address this, please create a box at 100m in Z axis and another at -100m in Z axis. Move the sun around and, you can see that the box that is in the positive range, casts sun shafts, the other one does not. This is the issue I'm facing with your system.
     
  20. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    I noticed the same issue. This error makes this asset completely useless for people who don't like floating point accuracy issues, since you are forced to move your world far away from the scene origin.
     
    Last edited: Aug 29, 2016
    Ravel likes this.
  21. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    @Ravel & StaffanEk
    I tested the atmospheric scattering scene that definitely missed the occlusion on the negative Z axis. I am investigating now.
     
    Last edited: Aug 30, 2016
  22. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    @Luckymouse

    Thank you very much for looking into this.
     
    Luckymouse likes this.
  23. Ravel

    Ravel

    Joined:
    Nov 21, 2010
    Posts:
    605
    @Luckymouse
    And another thank you from me to, because this is a huge thing and makes a huge difference for all of us :)
     
    Luckymouse likes this.
  24. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    Good news that I fixed the occlusion in negative Z issue. I will update the uSkyPro this hot fix in assets store soon along with other feature such as uSkyPro supports now WebGL build as well...etc.
     
    magique and JBT27 like this.
  25. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    874
    Any news on the clouds on 2.0?

    If you can't finish the new cloudsystem because of the technically issues, would it possible to combine the
    scattering fom 2.0 with the clouds of version 1.0?

    Thank you..
     
  26. CptBonex

    CptBonex

    Joined:
    Dec 14, 2013
    Posts:
    15
    Hi I'm having a problem getting scatter occlusion to work on my scene with usky pro beta. I have tried to copy the settings from the example but I'm not getting any result at all. however if I move the occlusion darkness slider I can see a very faint change in the tone of my scene but nothing else. I have tried to play around with all the sliders too but with no results. Any idea why I'm not seeing anything?

    Here is what I get:
     
  27. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    Yes, The older uSky 1.0 clouds is my final backup plan or something for mobile version for uSkyPro. However I believe the new cloud is still achievable. Right now I have some critical issues to solve, such as the framerate performance and realtime reflection probes supports etc. It just need time to accomplish. I do understand it is already taking too long, sorry for waiting.
     
    JBT27 likes this.
  28. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    Well, you did not enable the occlusion.
    Solution : Enable the "Use Occlusion" toggle under Atmospheric Scattering > Occlusion
     
  29. JBT27

    JBT27

    Joined:
    Jul 13, 2016
    Posts:
    197
    If you're reasonably confident of the new clouds working, then I'm fine with taking your time. Version 1.0 works for me at the moment.
     
    Luckymouse likes this.
  30. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    Hey guys I submitted the updated version to assetstore and Pending Reviewing now by Unity, Should be available soon.

    Coming version fixed the occlusion in negative Z-axis bug and support WebGL.
    You can check it out here the WebGL Demo. (8.5Mb)
    Note: Currently no occlusion on WebGL build that due to the limitation of the unity realtime shadow support on WebGL platform. (looking and working around other solution with it.)
     
    Last edited: Nov 6, 2016
    JBT27 and StaffanEk like this.
  31. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    874
    Okay, my idea for a current solution for usky2 is to overlay a transparent cloud skybox, 1) A skybox with the normal texture 2) a second one with a b/w mask.

    I want to look the sky through the transparency areas. I want to inclluude 2 cubesampler in your skybox shader and combine the results. Do you think thats possible?
     
  32. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    @Luckymouse

    Awesome. That WebGL Demo looks great. The demo doesn't work on mobile, which isn't surprising at all of course considering the complexity of this effect.

    Thank you very much for fixing the Z-axis bug.
     
    Luckymouse likes this.
  33. CptBonex

    CptBonex

    Joined:
    Dec 14, 2013
    Posts:
    15
    Oh I must have messed up when taking the screenshot and after playing around some more I noticed that if I move my terrain from -125 to 125 the occlusion starts working, strange. :/
     
    Last edited: Sep 15, 2016
  34. CptBonex

    CptBonex

    Joined:
    Dec 14, 2013
    Posts:
    15
    I have another question. Is it possible to alter the color of the skybox ocean? Since my scene is surrounded by water and I quite like the blend between the sky and the skybox ocean I would like to have that enabled for my game. But my water has a toon like look and is brighter and more colorful than the skybox ocean so they don't blend well together. I know this isn't a feature but if I could get a point in the right direction I would really appreciate it :)
     
  35. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    About the "cubesampler" that your mentioned here, I assume that you are talking two clouds cubemaps, right?
    I don't know what reason you want two cube maps, the clouds texture definitely need a mask, but it can be stored in one of the texture channel, so it does not need the second texture, just more optimized, right?
    if I misunderstand your question please explain more in detail.


    I tested the atmospheric scattering in my old iPhone 5, it is a bit slow but it actually works. Which mobile platform did you try, Android?
    I'm planning to re-work the atmospheric scattering for mobile later after new cloud implement.
     
  36. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    World Scale parameter is for atmospheric scattering, doesn't affect the occlusion. So your world size value does not matter here.
    There are still couple thing that required for occlusion. Please check your scene setup.
    1) At least enabled one of the Directional light shadow. In this case it is the shadow of sun light.
    The occlusion is using unity built-in shadow cascades map that generated by directional light.
    2) Enable Shadow Cascades in Quality Setting.
    3) Shadow distance in Quality Setting need to set to higher value (such as 500 to 1000 etc), this value is related with camera far clipping plane. In general that higher value of far clipping plane need higher value of shadow distance. So the distance (depth) of the occlusion appears same as where the realtime shadow is.

    Usually all this settings are already on by default scene and project setting. If you still have problem with it, please lets me know.

    Is the occlusion in the uSkyPro atmospheric scattering scene demo working for your?
    By the way which editor platform are you using, Mac or PC?

    For now, the answer is no and the only option is disable the skybox ocean.
    I did try to set some custom the color of the skybox ocean before, but result is just horribly ugly. I may try that again in future.
     
    Last edited: Sep 16, 2016
    HerrDarko likes this.
  37. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    @ nxrighthere
    So far I didn't find the performance issue for stars mesh generation, not sure why that happen to you. However I changed the code execution order of the stars mesh generation from Enable to Awake, it is more like how it works in uSky 1.x. Hopefully it fixed the problem for you in the next update.

    About the light map issue you got that I tested and can't replicate your problem here either. I'm still investigating it.
    Which platform are you on, Mac or Pc?
    Which unity editor version?
     
  38. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    I was talking about your WebGL demo. It isn't surprising that it doesn't work on mobile as it isn't supported. I used Android 5.
     
  39. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    You are right. Because the atmospheric scattering is running so slow on mobile, so the current atmospheric scattering shader is disabled for OpenES support, but the new updated version enabled for mobile again. ;)

    I was tested on old iOS devices and It works now, newer high-end devices should be faster. This is at least suitable for some architecture demo or prototyping build on mobile and show it for your client.
    Also you can the comment out "#define HORIZON_FIX" in Atmosphere.cginc for faster performance, By default it is always on, i think i may change it auto off for mobile later, since the screen pixels in mobile is general small, those artifacts may not noticeable on mobile anyway.

    Of cause the mobile skybox version is recommended for mobile as well.

    [EDIT]
    Surprisingly that the newest iPhone 7 (I don't have it yet) is actually running faster than my old macbook, and also the price for that you can almost buy a new laptop with it too.o_O
     
    Last edited: Oct 15, 2016
  40. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    New version 1.2.0f1 on the AssetStore.
    It is a hot fix update
    Change log

    - Now uSkyPro supports WebGL(HTML5) build. =================================
    Note:
    * This will work only in Unity editor 5.3.x or newer version, thus it is not supported in version 5.2.x. WebGL (Preview) build.

    * Currently support forward path only for atmospheric scattering to prevent the clipped specular with the material.
    That due to no camera HDR support in WebGL, it breaks the uSkyPro internal tonemapping of the scene. (Trying working around solution with it.)

    * At this moment Unity still does not fully support realtime Reflection Probe on WebGL platform.
    So you may experience some rendering error of reflection cubemap.

    * Currently occlusion may not work well that due to the limitation of the realtime shadow support on WebGL platform.
    Recommended it should be disabled on WebGL build for now.

    * "uSkyBoxPro mobile" material will work as well with faster rendering performance.
    ======================================================================

    - Fixed uSkyPro that has some compatible issue with PlayStation 4 build.

    ---------------------------------------------------------------------------------------------------------------------------

    - Occulsion: Fixed occlusion bug that missing in nagative Z axis.

    - Occlusion: Fixed some compatible issue of "AtmosphericScattering_Occlusion" shader with new Unity 5.4 shader API. (Removed "#pragma multi_compile SHADOWS_NATIVE" code.)

    - Occulsion: Now no matter MSAA (Anti-Aliasing) was enabled or disabled, the occulsion will always render with correct uv coordinate on Window based platform.
    (Occlusion pass will not flipped upside down anymore)

    - Occulsion: Added the "Occlusion Debug" toggle to drawn the occulsion pass only on screen.

    ---------------------------------------------------------------------------------------------------------------------------

    - Fixed atmospheric scattering artifact issue (Greenish on bottom) when sun is closed to horizon.

    - Fixed the uSkyPro has been multiply the exposure value twice in all the shaders.
    If your exposure parameter is not 1 (default value), than sky brightness may have slightly different. You may need to re-adjust it.

    - Fixed some swizzeling issue that between high and medium precision variables in the mobile skybox shader. So it is more optimized now.

    - Improved: Now Sun Disk has better rendering quality and added "Disable Sun Disk" toggle in uSkyPro setting.

    - Improved: The Reflection Probe will automatically update if any precompute parameters of uSkyPro that has changed.

    - Improved: The uSkyPro mobile material will render with better balance for sky brightness and reduced some darker area on the zenith of sky.
    If applied uSkyPro mobile material, uSkyPro will automatically set "Inscatter Altitude Sample" to X1, which it required.

    - Renamed "Runtime Time Slicing" from "RunTime Refresh Mode" in uSkyReflectionProbeUpdater script.
     
    Last edited: Sep 19, 2016
    nxrighthere, StaffanEk and JBT27 like this.
  41. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    460
    Looks nice, I need to increase light amount above 8! but it's limited to 8. please help.
    Thanks.
     
  42. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    uSkyPro clamped to max of 8 because that is exactly same as what unity directional light intensity can take.
    You can modify the Range setting in uSkyLighting.cs script (line # 31):
    Code (CSharp):
    1.         [Range(0f, 8f)][Tooltip ("Brightness of the Sun (directional light)")]
    2.         public float SunIntensity = 1.0f;
    You are welcome to change it and try, however I don't think unity light intensity will take more than 8.
     
    Crossway likes this.
  43. txarly

    txarly

    Joined:
    Apr 27, 2016
    Posts:
    197
    hi to all,

    i am thinking to buy a day/night package as Usky, but i am wondering how difficult is to implement rain,snow and wind with it.

    I am looking to use random effects with Usky, so if it is raining the sky and clouds must get darker.

    - Is this possible with Usky?
    -Do anybody know a weather package or plugin that works with usky?

    thank you

    txarly
     
  44. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    As you know that uSky does not have weather feature out of the box, it is just more focused on dynamic sky lighting for your scene right now. In general, it is definitely possible to implement other effect to your scene via some custom scripts to achieve your own weather system. Most of the uSky settings and materials can be control by your custom scripts. It is hard for me to say how difficult to implement it, it really depend on how you want your weather system to be. If you just load different scenes with different weather condition which I don't think it is hard. However if you want the dynamic weather within the same scene, it requires more scripting to do so.

    Just keep in mind that right now only the uSky 1.X version have the clouds, and it is using a static clouds texture.
    You can modify the shader to blend two different texture or fade the sky cloud color to grey to make clouds/weather transition..etc. The upcoming new procedural clouds for uSkyPro is still woking in progress, and it will be easier for dynamic clouds transition, but I don't have release date on that yet.

    As far as I know there are no third-party weather package for uSky yet. Please lets me know if anyone know it.

    Will sky add a weather feature? Yes, possible in future version, but it is not priority at the moment.
     
  45. asemenov

    asemenov

    Joined:
    Jan 13, 2014
    Posts:
    11
    Hi! I have a bug . Unity 5.4.1f1 // DX11 // Deffered // Linear. Latest uSky Pro Beta 2 v1.2.0f1/
    Skybox in reflection probe is completley black.
    Just create new scene, add uSkyPro prefab, create empty gameobject, add Reflection Probe Component, add usky reflection probe updater Component. Probe is updating but sky is always black. Same on baked probes.
    upload_2016-9-23_0-47-31.png
    I need to doublecheck, but I think it worked fine in 5.3.5p6
     
  46. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    Yes, I got the same bug on DX11. It was working fine on Mac. Sorry about that.
    Here is the quick fix:
    1)
    Open the uSkyboxPro shader
    Folder: uSky/uSkyPro Beta 2/Shaders/

    2) Edit line# 80: REMOVE the "* sign(_LightColor0.w)" code
    Code (CSharp):
    1. //change this
    2. OUT.Sun_g = PhaseFunctionG(.99 , _SunDirSize.w * scale * _uSkyExposure) * sign(_LightColor0.w);
    3.  
    4. //to this
    5. OUT.Sun_g = PhaseFunctionG(.99 , _SunDirSize.w * scale * _uSkyExposure);
    3) Save the file, and done!

    I also notice there are junk file in the uSkyPro beta 2 shader folder call: Clouds Advance.shader, it will occur error message in 5.4 editor and please delete this file.

    I will re-pack it and upload it to assets store again.

    [EDIT]
    Just found another bug regarding the new "Disable Sun Disk" function, if enable it the stars and space will appear on the bottom of the sky. Don't use it for now and I will fix it for next update.

    [Edit2]
    Submitted, new update is on the way.
     
    Last edited: Sep 23, 2016
  47. asemenov

    asemenov

    Joined:
    Jan 13, 2014
    Posts:
    11
    Thank you very much for a quick fix!
     
  48. jbakirli

    jbakirli

    Joined:
    Dec 31, 2015
    Posts:
    10
    @Luckymouse Can you show us how to use 1.x clouds with 2.x version?
     
  49. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    I believe it not that easy for me to show you how, it need to rewrite the clouds script and shader. Instead I will do it for you.:) I think I just need couple day for that, I will post it here if I finished.
     
    Last edited: Sep 27, 2016
  50. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    New version 1.2.1 on the AssetStore.
    It is a bug fix update for pervious uSkyPro version of 1.2.0f1. Please update this latest version.
     
    Last edited: Sep 27, 2016
unityunity