Search Unity

SilverLining for Unity: 3D volumetric clouds, sim-quality procedural skies [DEPRECATED]

Discussion in 'Assets and Asset Store' started by sundog, Oct 6, 2011.

  1. Leito

    Leito

    Joined:
    Apr 8, 2014
    Posts:
    37
    Thanks for the quick reply. I'll continue messing with it to see if I can get it to work.
     
  2. davidsirmons

    davidsirmons

    Joined:
    Mar 16, 2014
    Posts:
    190
    It's unexpected that it would add a few hundred draw calls. Where are they coming from? Certainly not the individual cloud count...? And I likewise can't imagine a real time 'volume' cloud rendering solution that could live under alpha checking through dozens of layers. Hopefully an 'overwrite pixel' math function has been researched, as well as a dynamic cloud LOD/mip approach?
     
  3. sundog

    sundog

    Joined:
    Dec 29, 2009
    Posts:
    429
    David, it's just the performance that matters at the end of the day. I see 250 FPS+ on a low end PC. Yes it is one draw call per cloud, but since they all share the same render state these draw calls are relatively inexpensive. And yes it splatting individual cloud puffs over each other without any fancy math functions, but the actual number of fragments affected are relatively small. We spent a lot of time tuning performance, and even tried implementing LOD and imposter approaches, only to find their overhead hurt performance more than helped it.

    We've also experimented with GPU ray-casting and found that our current approach outperforms it as well.

    Rather than worry about implementation under the hood, just check out the web demo and see for yourself how it works. http://media.sundog-soft.com/UnitySilverLiningWeb/WebPlayer/WebPlayer.html
     
  4. davidsirmons

    davidsirmons

    Joined:
    Mar 16, 2014
    Posts:
    190
    I'll certainly take a look at it. The game I and another member here are making will rely on flight by the characters, and super high speed flight at that, over large distances. Procedural worlds/terrain/scattered terrain objects/clouds is our only option, so at less than $200, SilverLining is a steal, for sure. I also took a look at Triton, your ocean/water body simulator and it looks fantastic. Does it allow swell and local displacement for large objects exiting/entering the water?
     
  5. sundog

    sundog

    Joined:
    Dec 29, 2009
    Posts:
    429
    Yup! You'll need to do some scripting to get access to the underlying Triton::Environment::AddSwell() API, but there is an included Impact object you can use for displacing the water from local disturbances. There's also rotor wash and ship wake effects. More info on Triton for Unity Pro is at http://sundog-soft.com/sds/features...nity-water-effects-with-triton-for-unity-pro/ and there's a free trial as well.
     
  6. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    we get last patch note somewhere please ?
     
  7. sundog

    sundog

    Joined:
    Dec 29, 2009
    Posts:
    429
    Hi,

    The most recent change was in August, and just fixed a bug in how the "cloud brightness" setting was applied.
     
  8. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    oh yes and about fog it's possible to combine now i see on post she talking about but not sure understand
     
  9. sundog

    sundog

    Joined:
    Dec 29, 2009
    Posts:
    429
    The short version is: as long as you have "apply fog to sky dome" enabled in the _SilverLiningSky prefab, the sky should blend with your fog automatically in the current version. It will use the fog color and density in your render settings to work with; in my case, I have a grayish-yellow fog color with Exp2 and density of 0.001 and it looks good.
     
  10. broesby

    broesby

    Joined:
    Oct 14, 2012
    Posts:
    118
    I am close to buying SL on sale....

    But before buying I need to inquire on the "tree billboard issue" reported above...

    That might be a huge turn-off for me. I have lots of trees which leads to lots of trees in the distance as well.
    I am airborne. That's one reason I want the volumetric skies in the first place..

    But to have all the trees in the distance be visible through the clouds would be a complete no go.

    On the other hand I would like to be able to see the trees when I am below clouds as most of the time...

    I don't understand. That must be an issue for a whole lot of people?

    Plz, remedy my worries ;-)
     
  11. sundog

    sundog

    Joined:
    Dec 29, 2009
    Posts:
    429
    It is still an issue that is present in Unity as far as I know. There is the workaround described in this post: http://forum.unity3d.com/threads/si...y-procedural-skies.107166/page-4#post-1643393 that reportedly works, but it does involve going "under the hood" in Unity to fix how billboard trees are sorted relative to other transparent objects (like our clouds).

    I've worked around it by moving the trees into their own camera, which gives me greater control over when they render relative to the cloud particles.

    Surprisingly it's not something I hear about too often from customers. Whether it's a problem for you depends on how your scene and camera viewpoints are arranged, but to be honest it does sound like something you'd have to address in your application.
     
  12. broesby

    broesby

    Joined:
    Oct 14, 2012
    Posts:
    118
    On to something else:

    Any known compatibility issues with

    - Terrain Composer (I suppose not)
    - RTP3 (... bigger issue there maybe)
    - Advanced Foliage Shader (potetially big issue for trees since AFS works best if it takes over control over ambient light)

    Thx in advance,

    Jesper, Denmark
     
  13. sundog

    sundog

    Joined:
    Dec 29, 2009
    Posts:
    429
    I don't own any of those assets, so I don't know for sure. Nobody has ever reported any problems with them together with SilverLining. But, as this is really a more general issue about transparent objects in Unity you're probably better served by searching the forums on those assets for any general problems about sorting with transparent objects and/or particles. It really comes down to how they manage the sorting of the trees.

    Regarding the ambient light comment - you can always disable SilverLining's built in light sources if you want something else to manage the scene lighting.

    HTH.
     
  14. broesby

    broesby

    Joined:
    Oct 14, 2012
    Posts:
    118
    Thx,.. ;-)

    I think I accidentally wrote a question inside the quotes... Regarding the tree billboard issue and the "hotfix" you mentioned:

    Do you think it could it be possible to have two Silverlining scripts and then toggling between the two depending on player altitude?? Or would that require the whole cloudscape to be regenerated each time the scripts would toggle??
     
  15. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    can't see Cumulus Clouds with low fog like this one fog color with Exp2 and density of 0.001

    i have check the shader Fog is { Mode Off }

    what's happen
     
  16. sundog

    sundog

    Joined:
    Dec 29, 2009
    Posts:
    429
    SilverLining's a fairly complicated asset, so it's not just a matter of toggling a script. There are a lot of components to it.

    Not 100% sure what you're after, but if it's switching between two differently configured cloud layers at runtime, that would require some modifications to SilverLining. Under the hood there is a SilverLining.cs script that manages the different cloud layer objects. To keep the UI simple, it only manages a single cumulus cloud layer, which is implemented by the SilverLiningCumulusCloudLayer.cs class. If you're at all handy with C#, it wouldn't be hard to expose a second cumulus cloud layer in SilverLining.cs and the ability to switch them on and off individually at runtime.
     
  17. sundog

    sundog

    Joined:
    Dec 29, 2009
    Posts:
    429
    My guess would be that you have "apply fog to clouds" checked. A fog density of 0.001 with exp2 equates to a visibility of around 1 KM. The clouds are higher than that, and so they are not visible.

    Try unchecking "apply fog to clouds" and you'll probably get the results you expect.
     
  18. Rtyper

    Rtyper

    Joined:
    Aug 7, 2010
    Posts:
    452
    Pretty nice asset, I'm liking it so far, though I am getting a few small problems with it. I'm using this in a tycoon/management style game where you run an airport, so clouds are naturally fairly important!

    The first thing is that the sunsets/sunrises get unnaturally orange/bright all the way around from the fog, and stars at night seem to be obscured when I have apply fog to sky dome set on.

    The other thing is how the clouds transition between different lighting states. I'm using a very high continuous time advance rate (500 is "normal" speed, with the option of going up to 8000 for speeding up time to pass through days quickly), which causes issues where the clouds will be still lit like its sunrise at midnight, then 'pop' into nighttime lighting one by one. I get this is more from my usage of it than your system, but I wondered if you had any way of improving this?

    I'd try to fix these things a bit more myself, but the lack of documentation saying exactly what everything does makes it a little more difficult. :)

    Thanks.
     
  19. sundog

    sundog

    Joined:
    Dec 29, 2009
    Posts:
    429
    I agree the sunlight color once the sun just gets below the horizon is a little over the top when fog is on. There are a few things you can tweak in our scripts to combat this.
    • In SilverLining/Src/SilverLiningSky.cs, change the value of "oneOverGamma" on line 47 to 0.41.
    • In SilverLining/Src/SilverLiningSky.cs, change the value of "baseFogColor" on line 57 to new Color(0.7f, 0.9f, 1.0f, 1.0f);
    • In SilverLining/Src/SilverLiningLuminanceMapper.cs, change the value of "brightness" on line 8 to 1.2.
    I'll make those the new default values in our next release.

    The stars are not visible in the presence of fog by design. But you can influence how fog is applied to the stars by messing how how far away they are treated as being by the fog equations. On line 9 of SilverLining/Src/SilverLiningStars.cs you'll see a setting for "starDistance". If you reduce this value, the stars will punch through the fog more.

    The "popping" of cloud lighting with highly accelerated time passage is something we do to preserve performance; we limit the number of clouds that have their lighting recomputed per frame. Turning up the value for "cloud updates per frame" should help with that - it's a setting in the _SilverLiningSky prefab.
     
  20. Rtyper

    Rtyper

    Joined:
    Aug 7, 2010
    Posts:
    452
    Great, thanks - that looks much better now!
     
  21. wetcircuit

    wetcircuit

    Joined:
    Jul 17, 2012
    Posts:
    1,409
    Hi, thank you for the very cool clouds (and the sale) :cool: You posted on your blog that you had tried Silverlining in Unity5beta, I wanted to try it out and it looks fantastic.

    but... I think possibly the ambient color is not effecting the cumulus clouds...? Ambient on the clouds always seems to be tinted grey/blue-ish - maybe that is working as intended and clouds are not actually effected by scene ambient color...?

    :rolleyes: of course I am being difficult and trying to use Silverlining's cumulus clouds with a different 3rd-party sky to get hdr IBL and "alien" sky colors, which is why I'd like to change the ambient tint. (I've got SL controlling the other sky's sun position, so they work together nicely).



    I know it's too early to support U5, and I (unsuccessfully) attempted some of the user hacks described in this thread to get control of the ambient (I'm not a coder). Setting the scene's Ambient Source to Color and selecting a colorchip doesn't effect them.... (Also tried the cloud's Start Color but that's probably not what I think it is...) I'm still looking for a workaround but I thought I would mention it, maybe something to look at as I think U5's default ambient lighting is changing to "Skybox" in U5....

    Thanks! :) If you have a suggestion (or I am just off base), advice appreciated.
     
  22. sundog

    sundog

    Joined:
    Dec 29, 2009
    Posts:
    429
    Under normal operation, SilverLining will set your render settings' ambient light based on its own sunlight scattering model every frame. It's not a Unity 5 thing I think, it's just doing what SilverLining does - it provides realistic ambient and diffuse lighting for your scene for the time of day and location you are simulating.

    The Unity 5 problem is likely that SilverLining is not adjusting the ambient color for your scene because of this bug in Unity 5's current beta. You're right that we should probably also adjust the skybox ambient light in addition for Unity 5 though.

    However, changing that behavior so SilverLining uses whatever ambient light you specified in the render settings is a one line change. If you open up SilverLining/Src/SilverLiningSky.cs, you should see this at around line 609:

    RenderSettings.ambientLight = skyLight * ambientLightScale;

    If you comment that out, SilverLining will use your render settings ambient light instead of the other way around.

    Also be aware of the settings in the prefab to scale the amount of ambient and diffuse light used to light the clouds - this can be very useful in tuning their brightness to match the rest of your scene.

    Hope this helps.
     
    Last edited: Nov 26, 2014
    wetcircuit likes this.
  23. Non Hic

    Non Hic

    Joined:
    Feb 4, 2015
    Posts:
    95
    Just bought this. Fantastic!

    Questions:

    1. I added this to my scence. How do I alter the wind speed at run time?
    (I need C# code sample please)

    2. Where should this code be, in the "Update"?

    Thank you.
     
  24. sundog

    sundog

    Joined:
    Dec 29, 2009
    Posts:
    429
    You just need to grab your scene's SilverLining object, like this:

    SilverLining silverLining = (SilverLining)(GameObject.FindObjectOfType(typeof(SilverLining)));

    Then, you can use any of its public members or methods. Like:

    if (silverLining != null)
    {
    silverLining.windVelocity = new Vector3(100.0, 0.0, 0.0);
    }


    Doing this from an Update method somewhere would be fine.
     
  25. Non Hic

    Non Hic

    Joined:
    Feb 4, 2015
    Posts:
    95
    Thank you very much! (silverLining.windVelocity = new Vector3(100.0f, 0.0f, 0.0f):p
     
  26. sundog

    sundog

    Joined:
    Dec 29, 2009
    Posts:
    429
    Ah yes. Those f's are the bane of my existence!
     
  27. Non Hic

    Non Hic

    Joined:
    Feb 4, 2015
    Posts:
    95
    Sorry to bother you again, how do I change the Y position of the clouds? To get them "come down"? I see it in the editor under "transform" section but unsure how to reach it by code?
     
  28. Non Hic

    Non Hic

    Joined:
    Feb 4, 2015
    Posts:
    95
    Oh never mind. It's the "altitude" I should use I suppose.
     
  29. Non Hic

    Non Hic

    Joined:
    Feb 4, 2015
    Posts:
    95
    This gives me error:
    silverLining.altitude = Convert.ToInt32(Mathf.Lerp(silverLining.altitude, newIntensity, smooth * Time.deltaTime));

    Because altitude is double but lerp eats a float. Any idea how to solve this? I am unable to convert the double to float in Unity so how would I use a lerp function in the altitude of the clouds in this case?
     
  30. sundog

    sundog

    Joined:
    Dec 29, 2009
    Posts:
    429
    No, the altitude represents the altitude of the observer, not the clouds.

    Each cloud type has a position vector. For example there is a cumulus position, and the altitude of the cumulus clouds is given by its Y component. You'd access this exactly the same way as the windVelocity, just use cumulusPosition instead of windVelocity.

    It might be a good idea to play around with the different properties of _SilverLiningSky in the editor first, so you get a feel of the effect they have.
     
  31. Non Hic

    Non Hic

    Joined:
    Feb 4, 2015
    Posts:
    95
    I see it now. Thank you very much! Excellent support.
     
  32. EvilDingo

    EvilDingo

    Joined:
    May 7, 2011
    Posts:
    190
    Is there any easy way to resize the clip plane so everything can be seen? 100km is not feasible in my game because it creates many, many more tris over the terrain. I tried limiting the sun and moon to 20km but it's not really working out. The stars look very strange at 20km limit. I can actually fly through them. The cirrus clouds also don't look right.

    100km clip plane causes other issues like z-fighting. Even 20km is a bit extreme for me, but I think I can work around that.
     
  33. sundog

    sundog

    Joined:
    Dec 29, 2009
    Posts:
    429
    Is it possible to move out your near clip plane a little instead? A small increase in the near clip is usually all it takes to overcome z-fighting.

    A 20km clip plane means you won't see many clouds - they are usually around 6km up after all, so 20km won't allow you to see clouds in the distance. So it might be best to figure out how to LOD your terrain more aggressively instead.

    However, to answer your question - try changing line 256 of our SilverLiningStars.cs script to:

    particles.position = convertedPos + Camera.main.transform.position;

    This will cause the stars to work properly with a smaller sky dome size. Sounds like you've already figured out how to adjust the size of the sky and the distance to the moon and sun.
     
  34. EvilDingo

    EvilDingo

    Joined:
    May 7, 2011
    Posts:
    190
    I can only move the near plane a few meters (2ish) before it starts to interfere with my models. That's not enough to fix the z-fighting unfortunately.

    It's possible I could LOD the terrain, but I'm still not sure about the z-fighting.

    If there was a way to adjust the sky dome to the camera's clip plane, this asset would be kicked up another notch I think. It already looks great even at a smaller clip plane. I adjust the fog so there is no real pop-in and the performance is impressive.
     
  35. sundog

    sundog

    Joined:
    Dec 29, 2009
    Posts:
    429
    You can adjust the sky dome size by adjusting the scale on the _SilverLiningSky object, but it's only 1000 meters by default so it shouldn't interfere with any reasonable far clip distance.

    Adjusting the distance to the stars, sun, and moon require changing parameters in the SilverLiningStars.cs script and SilverLiningSky.cs script (look for sunDistance, moonDistance, and starDistance.) Line 75 of SilverLining.cs is where the 100km far clip plane is set if you want to change it.

    Normally a near clip of 1.0 and far clip of 100,000.0 avoids most z-fighting issues - if you're still seeing that, you may have some unusual situation with lots of coplanar polygons going on. I don't really want to make it too easy to use SilverLining with small far clip planes - if I did that, I'd be inundated with people complaining about why they only see clouds right next to the camera! But hopefully this gives you the guidance you need for your situation.
     
  36. EvilDingo

    EvilDingo

    Joined:
    May 7, 2011
    Posts:
    190
    Thanks for the suggestions. I do have some co-planar issues (water and the seabed beneath) that is probably specific to my project.

    This is a great asset. I avoided it for a long time because somewhere along the line, I thought it required a .DLL and that is usually a deal-breaker for me. I essentially have 100 square km of terrain with a great sky and clouds you can fly through. No other asset does that with this kind of performance.

    I have a suggestion for future updates though! The night sky is currently completely black. Even starlight lights the surrounds somewhat. I have to boost the ambient level x10 at night to get something the player can see. I think there should be a lot more twilight and the night darkness ambient level should be higher. Or at least and easy option to change it. Boosting the ambient level globally just causes daytime to be overbright.
     
  37. sundog

    sundog

    Joined:
    Dec 29, 2009
    Posts:
    429
    Thanks for the suggestion! Choosing a night to simulate with a full moon might help a little for now.
     
  38. DCrosby

    DCrosby

    Joined:
    Jan 13, 2013
    Posts:
    86
    I saw a quick blurb about Oculus and Silver Lining, and how once camera was lagging, I'm using Unity 5 Pro, and I can't get the clouds to appear in the right eye. Any ideas ?

    Also on Unity 5 Night time becomes bright white / corrupted, as Unity 5's new shader model interprets textures for environments (skyboxes) differently, even it's own skybox textures have to be re-computed to not show white or black holes in the sky. (no not clouds :D ) I Haven't done much research as to how to fix it, just went back to a skybox, and found a similar issue there, and then connected the dots. But those two issues are preventing me from using SL in my Oculus Unity 5 environments.

    -DC
     
    Last edited: Mar 17, 2015
  39. sundog

    sundog

    Joined:
    Dec 29, 2009
    Posts:
    429
    DC,

    I answered your first question previously via email, but for the benefit of others - make sure the right eye camera's far clipping plane is set to 100,000. It probably doesn't match the left eye camera's far clip distance and so the clouds are being culled out.

    I don't see any issue with night time scenes with SilverLining on Unity 5 under Oculus (see screenshot below.) Are you using the latest version of SilverLining? It should include a demo Oculus scene which is all I'm showing here. If you can reproduce what you're seeing using the demo scene, let me know what settings you had to change to make it happen. SilverLining's sky is just a dome centered over the camera - it's not a Unity skybox so there's nothing special about it.

     
  40. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Is there a way to set SL so we have 24-hour day/night cycle, but the date does not advance? I need to lock in a particular date and have the day/night always loop on that date.
     
  41. sundog

    sundog

    Joined:
    Dec 29, 2009
    Posts:
    429
    Not automatically. You'd have to modify our scripts.

    In Resources/SilverLining.cs, look for the Update() method. You'll see where time is advanced:

    if (continuousTimeAdvance) {
    float elapsed = Time.deltaTime * continuousTimeAdvanceRate;
    time.AddSeconds (elapsed);
    year = time.GetYear ();
    month = time.GetMonth ();
    day = time.GetDay ();
    hour = time.GetHour ();
    minutes = time.GetMinute ();
    seconds = time.GetSeconds ();
    }

    So, I think if you just comment out the lines that assign, year, month, and day to the new values, it will stick with the date you started with.
     
  42. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    That worked! Thanks!!

    So another question: Maybe this is obvious and I'm just not seeing it, but can I set the nighttime ambient lighting (in Unity 5) somewhere? It defaults to black but I need a brighter nighttime.
     
  43. sundog

    sundog

    Joined:
    Dec 29, 2009
    Posts:
    429
    You can view the ambient light by going to the Window menu and selecting Lighting, then selecting the scene tab. If there is a moon out, the night ambient light should be more than just black.

    If you want to simulate light pollution to make night scenes brighter, look at line 1251 of Src/SilverLiningSky.cs:

    public double lightPollution = 0;

    I think this value is in nits, so a value like 0.01 would be extremely polluted for example.
     
  44. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Thanks!

    But the moonlight is always black, even when a fullmoon is overhead--see screenshot. I'd like to fix that...though what I really want to do is change the color of the moon, or of the nighttime ambient light. Is that tweakable?
     

    Attached Files:

  45. sundog

    sundog

    Joined:
    Dec 29, 2009
    Posts:
    429
    If you click on the color, I think you'll find that it's not actually black, just a very dark color (unless you have other modifications that are affecting it.) You can use the moon light scale parameter in the _SilverLiningSky prefab to boost that if desired.
     
  46. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Ah, yeah, I can crank that way up. Can I change the color of the moonlight (make it bluer)?
     
  47. sundog

    sundog

    Joined:
    Dec 29, 2009
    Posts:
    429
    The moonColor value gets computed toward the end of SilverLiningSky::UpdateMoon(). I suppose you could multiply the blue component by some constant of your choosing in order to boost it.

    If you want to do something a little more realistic, you could expose the "k" member variable in SilverLiningLuminanceMapper.cs, and use it to blend between the real moonlight color and a dark blue color of your choosing. That way, the night will appear more blue as the eye adapts to lower light levels, simulating how your brain creates that illusion.
     
  48. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Hmm, I'm not having any luck with that, no doubt because I don't understand the code. Can you give me more pointers? :)

    Also: I need to rotate the SL dome so North is what's currently West. (That is, rotate the dome/sun path 90 degrees counterclockwise.) Rotating the prefab doesn't affect the sun's path. Can I rotate it some other way?

    thanks!
    Dave
     
  49. sundog

    sundog

    Joined:
    Dec 29, 2009
    Posts:
    429
    My mistake - UpdateMoon() computes the color of the moon disc itself. The moon light is in SilverLiningSky.UpdateLight(). Look for this line:

    Color moonLightColor = new Color (rgb.x, rgb.y, rgb.z);

    So, to double the blue component you could do something like:

    Color moonLightColor = new Color (rgb.x, rgb.y, rgb.z * 2.0f);

    As you've seen, SilverLining assumes that the X axis is "East" and -Z is "North." To change this, you'll need to modify some more code.

    First in SilverLiningEphemeris.cs, the ConvertAxes method is what defines this convention. So for the one I think you want, you could modify it like this:

    private Vector3 ConvertAxes (Vector3 v)
    {
    // Oriented -x=n z=up y=east
    Vector3 tmp = new Vector3 ();

    /*
    tmp.x = v.y;
    // x is east
    tmp.y = v.z;
    // y is up
    tmp.z = -v.x;
    // -z is north
    */

    tmp.x = -v.x;
    tmp.y = v.z;
    tmp.z = v.y;

    return tmp;
    }

    That will make sure the sun and moon are where you want them (and this also drives the sky colors.) The other piece is the position of the stars. In SilverLiningStars.Update(), you'll need to change line 255 like this:

    //Vector3 convertedPos = new Vector3(pos.y, pos.z, -pos.x);
    Vector3 convertedPos = new Vector3(-pos.x, pos.z, pos.y);

    Hope this helps.
     
  50. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Perfect! Thanks so much for the help.