Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Open Source Atmospheric Scattering

Discussion in 'Works In Progress - Archive' started by Michal_, Jul 30, 2016.

  1. Sp-ce

    Sp-ce

    Joined:
    Feb 2, 2015
    Posts:
    65
    @Michal_ This is really cool - thanks for putting it together!!

    Got it working just in the 5.6 latest beta as of this post.
     
    Michal_ likes this.
  2. wsz

    wsz

    Joined:
    Oct 20, 2012
    Posts:
    19
    I did these steps but is not working. I'm using Unity 5.5.2.f1 (Windows), GTX 1070.
    • Add AtmosphericScattering script to your camera.
    • Set your main directional light as a sun. (AtmosphericScattering script/General Settings/Sun)
    • Set AtmosphericScattering compute shader (AtmosphericScattering script/General Settings/Compute Shader)
    • Create material with "Skybox/AtmosphericScattering" shader and set it as skybox in Window/Lighting/Skybox.
    • Set Camera clear flags to "Skybox"


    • img.jpg
     
  3. wsz

    wsz

    Joined:
    Oct 20, 2012
    Posts:
    19
    In Play Mode is not working.
     
  4. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Is the example project/scene working on your computer? Any errors in console or on the AtmosphericScattering script?
     
  5. Flurgle

    Flurgle

    Joined:
    May 16, 2016
    Posts:
    389
    Can confirm there are problems with 5.6

    The skybox renders Black, but there are no errors.

    The only shader / script with errors seems to be the compute script. I fixed that, and the scene sorta works with the default skybox, though I'm not sure if the scattering fog settings are doing anything.
     
  6. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Works for me with 5.6.0f3 on Windows. The only known issue is MSAA which breaks it on some Untiy version. Are you perhaps on a platform other than Windows?
     
  7. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    you know i do use this a lot. i would like to request in editor functionality. skybox is rendering only in playmode right?
    or am i doing something wrong?
     
    Flurgle likes this.
  8. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Yeah, it is for playmode only. Your request is noted. I'll see what I can do.
     
  9. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    this would be great would make tweaking much easier
     
  10. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Wow, that looks great. Whatever it is :)

    I added experimental support for rendering in edit mode. I'm not really sure about it, so I put it in separate branch. I don't have much time with E3 behind the corner. Look for "SceneViewSupport" branch and let me know if it works. You'll need at least unity 5.4.
     
  11. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    thanks a lot ill test it. good luck with your e3 preparation - can you say what title it is?
    this also uses your atmospheric scattering btw
     
  12. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    in game window it works in scene view it does not. flickering and wrong sun direction
    Can't destroy Transform component of 'ReflectionProbe'. If you want to destroy the game object, please call 'Destroy' on the game object instead. Destroying the transform component is not allowed.
    MissingReferenceException: The object of type 'Light' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    AtmosphericScattering.ComputeLightColor () (at Assets/Scripts/AtmosphericScattering.cs:609)
    AtmosphericScattering.Update () (at Assets/Scripts/AtmosphericScattering.cs:681)
    Can't destroy Transform component of 'ReflectionProbe'. If you want to destroy the game object, please call 'Destroy' on the game object instead. Destroying the transform component is not allowed.
    UnityEditor.DockArea:OnGUI()

    focus on e3 first but maybe for the long term
     
  13. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    No. Big company. Everything is secret. Even already announced titles :)

    That's a shame. It worked for me. Did you try example scene? And what unity version do you use?
     
  14. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    i see ;D top secret ;D - i got the flickering even without atmospheric scattering ill try it at home and will give you feedback
     
  15. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    and another one heavily relying on your assets
     
    mcbauer and RomBinDaHouse like this.
  16. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    very nice video, how do you applyu the color? using area light or emissive light? very neat tho.
     
  17. TheCelt

    TheCelt

    Joined:
    Feb 27, 2013
    Posts:
    741
    I have lighting box which uses your volumetric lights, does the atmospheric scattering also work with that asset?
     
  18. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    check two post above! yes it does
     
  19. Nighs

    Nighs

    Joined:
    Jul 8, 2017
    Posts:
    3
    Can I use your script in my projects that I view in the asset store? Some scenes and more?
     
  20. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Sure. Do anything you want with it. The models/textures are from the Unity Blacksmith demo by the way. I'm not sure I mentioned in the readme.
     
  21. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,369
    Atmospheric should include thick height fog. There is a great free project available here:
    https://forum.unity3d.com/threads/screen-space-multiple-scattering.446647/

    I tested it and it works nicely with Open Source Atmospheric Scattering. However, the for color has to be adjusted manually to take time of day into account.

    It would be great if you could integrate the linked height fog solution into your project and link the fog color to the sun.
     
  22. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Cool project. I always used depth of field for underwater "fog" but I never thought about using it for atmospheric fog. It looks great with a heavy fog.
    I'm not going to integrate one github project into another one. I don't want to keep that up to date. It should be easy enough though. Just take directional light color and set it as a fog color. You may want to decrease intensity and/or desaturate the color a little bit to avoid bright colorful fog at sun rise. And that should be it.
    I can help with it if there is a problem.
     
  23. vistaero

    vistaero

    Joined:
    Mar 23, 2017
    Posts:
    10
    Hi, did you do any advance on compatibility with Metal? this doesn't work on my hackintosh. I have Windows too for developing but I would like my game to be compatible with at least Windows and macOS.

    If you need macOS for testing, you can connect to my computer via TeamViewer.
     
  24. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    Hi Michal as you know i use your atmospheric scattering a lot. in combination with kode clouds it looks very impressive. there is one thing bothering me. kode is not replying to anything so we cant expect anything to change on his side but maybe you can fix it (thanks again for the scene viewport support). your skybox is rendered below the horizon. this is very important and the effect is very good. as soon as i render the clouds on top the horizon gets cut off. could we force some order or importance below the horizon? i would aprecciate any hint or fix on that topic!
     
    Last edited: Nov 1, 2017
  25. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Sorry, I didn't notice your post somehow. No change about Metal. I don't really know much about it. I don't like Mac to be honest and I don't want to spend my free time on this.
     
    Martin_H likes this.
  26. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    I don't know anything about kode clouds. I'm not even going to bother googling that to be honest. But I will take a look if you send me minimal repro project. Like the one on the screenshot. I don't want to waste my time trying to figure out where to get the plugin, how to setup it etc.
     
  27. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    ill send you a small package!
     
  28. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Thanks. Now I understand. That blackness below horizon is actually by design. The fact that you don't see it all the times is some kind of bug.
    The system simulates spherical planet inside spherical atmosphere. You can't see atmosphere below horizon because it is obscured by the planet. You can see how that changes if you move your camera high above the "ground".
    If you want to see atmosphere below horizon then you need to ignore the planet. Look at AtmosphericScattering.compute and comment out lines 292 and 293. That should do the trick.
     
  29. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    ill give it a try. thanks a lot!
     
  30. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    924
    Hi there!

    for those interested, here's my early attempt of porting Open Source Atmospheric Scattering
    to Unity 2018.1.6f1, merging the only 2 on 37 available forks:

    - Fixed all Warnings
    - Fixed all in-editor errors
    - Fixed all obsolescence issues
    - Fixed all compute shader warnings
    - Patched Sample Scenes with Processing Stack v1 (Unity Store)
    - Fixed Player settings
    - Dumped obsolete Project settings
    - Tweaked Quality Settings
    - Defaults to Linear color space/deferred

    Enjoy, and thanks for making this asset open source! :)

    https://github.com/NeatWolf/AtmosphericScattering/tree/Unity2018

     
    khos, thieum, IsDon and 7 others like this.
  31. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Thank you sir
     
  32. Flurgle

    Flurgle

    Joined:
    May 16, 2016
    Posts:
    389
    @NeatWolf Now that Deepsky Haze is no longer on the asset store, this fills the void. Thank you so much!
     
    NeatWolf likes this.
  33. ThePortOfRiches

    ThePortOfRiches

    Joined:
    May 25, 2013
    Posts:
    4
    I'm trying to figure out how to get this to work on a sphere. Anyone have any ideas?
     
  34. Rensoburro_Taki

    Rensoburro_Taki

    Joined:
    Sep 2, 2011
    Posts:
    274
    I have to revive this thread, cause it must not die! Sadly, I have no programming skills. Otherwise, I would have already set to work.

    There is actually no atmospheric scattering solution for Unity 2018.3 out there. The actual version makes some flickering when using light shafts. Otherwise it runs perfectly!

    It needs just a small fix! I think so...

    so great - would be a big loss if it dies....
     
    NeatWolf likes this.
  35. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    924
    I'm going to have a look at it asap, I had/currently have very little spare time :oops:
    (I'm not the dev btw, I thought it was a pity to let it die ^_^")
    Gotta check if there have been more public forks branching from mine in the meanwhile.
    Problem is: most of the forks of the project were not public :/

    Btw: on which version is it flickering? Building for which platform+version?
     
    Last edited: Feb 22, 2019
  36. Rensoburro_Taki

    Rensoburro_Taki

    Joined:
    Sep 2, 2011
    Posts:
    274

    omg, the "gods" have sent me an angel =)
    ....
    ..
    .

    Hey!

    It's just a pain for me as a designer to see all my environments without that amazing finishing touch! And I'm not exaggerating. :/

    Therefore, 1000 thanks for your effort!

    Issue
    When activating "light shafts" a diagonal dark and straight shadow starts to appear over the skybox. Of course I am using the included atmospheric skybox/shader!) Also, the shafts do not show up correctly. I guess. They somehow look inaccurate, even on high detail settings. And when rotating, the big shadow starts flickering.

    Btw, what does "write to LUT table" do? Cause it changes my ambient light and maybe other settings. And I am currently working a big project and I have no clue it really does and where it makes changes.

    Here is my setting:
    • 2018.3.0f2
    • multipass rendering (seems to work only with multipass)
    • linear color mode
    regards
     
  37. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    I tried to run the sample scene from my github repo in Unity 2018.3.6f1 and it works fine. I don't have VR to test multipass rendering though. Is it working outside of VR for you? Maybe try newer Unity version.

    Do you mean "Update LookUp Tables" button? Some of the settings are not updated in realtime and you have to click that button the see the changes. But maybe you're not using my original version and it works differently in whatever version you have?
     
  38. Rensoburro_Taki

    Rensoburro_Taki

    Joined:
    Sep 2, 2011
    Posts:
    274
    the problem occurs already in the viewport. I atm not infront of my PC, but could it maybe be cause of a to wide camera range? Cause in my case I use 60.0000 xD

    i downloaded it on dez 2018 from your github repository. As soons as I am back to my PC I will download the latest and test this one with my actual unity version, which is already the 1st 2018.3 release. But what would interest me still is, where does the button make its changes?

    best regards[/QUOTE]
     
    Last edited: Feb 24, 2019
  39. Rensoburro_Taki

    Rensoburro_Taki

    Joined:
    Sep 2, 2011
    Posts:
    274
    I found out where the problem lies, just can't locate exactly its "position" xD

    So far, I've always skipped to use your project settings, made the shader entry manually, and just copied the assets. Ive now overwritten my project settings with yours and taraaaa - everything is working fine! =D Nice, but what else exactly is anchored in the project settings, except the one always-load-shader-entry, that is only for standalone? This would be very helpful for me to know.
     
  40. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    All the files in ProjectSettings folder are simple text files. You can open them in any text editor and take a look. Problems with light shafts suggest it is related to shadow settings. Probably shadow distance or some cascade shadow settings in Quality settings...
     
    NeatWolf likes this.
  41. Rensoburro_Taki

    Rensoburro_Taki

    Joined:
    Sep 2, 2011
    Posts:
    274
    I see, thanks for all the effort & help!

    So nice - everything now shines ! =)
     
    Last edited: Feb 24, 2019
  42. Rensoburro_Taki

    Rensoburro_Taki

    Joined:
    Sep 2, 2011
    Posts:
    274
    Swichting Shadow Projection in ProjectSettings > Quality to Stable Fit solved the big "shadow-slice" problem! =)

    If I were you, I would make a package ready for the asset store! =) This is the most important fx for every big outdoor scenery. Thank you for making this possible!

    New.JPG
     
    Last edited: Feb 25, 2019
    Flurgle, Baldinoboy and manpower13 like this.
  43. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    You're welcome! I'm happy that somebody found it useful. I'm way too busy to support proper asset store package so this will have to do.
     
  44. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    @larsbertram1, Would be awesome to get this solution compatible with Lux Water if possible.
     
    hopeful likes this.
  45. Tasarran

    Tasarran

    Joined:
    Jan 20, 2011
    Posts:
    327
    Does anyone have any ideas about how this could be made to be rotatable?
    It seems like I should be able to specify a location of the center of the planet, calculate the actual height and local up from the position of the camera and this location, and apply one matrix/quaternion to the end result...?