Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Free Realime Atmospheric Scattering Based on Unity Blacksmith

Discussion in 'Works In Progress' started by Ysgramor, Aug 2, 2016.

  1. Ysgramor

    Ysgramor

    Joined:
    Jan 23, 2014
    Posts:
    69
    Hi all,
    Lately im try to modifying Unity Blacksmith Atmospheric Scattering to make it change color on realtime.
    Since there.s just few free one on the Community, so im share my work here.
    Basically im just add Preetham formula to Blacksmith Scatter.

    Preetham formula based on http://jasperhoughton.com/

    This shader still heavy i think, just like the blacksmith one

    since my shader knowledge just a basic :D and Im not good at math and caclculation, maybe some wrong calculation happen here :rolleyes:
    I hope someone whose expert at shader can optimize this shader.

    Suggestion and bug report much apreciated.


    Download file attached (package version and zip version)
    Using Unity 5.4 stable

    Demo scene included.

    How To Manual Setup:
    - Make sure to add scattersky material to unity skybox
    - Set lightning as Deffered (since this is deferred only)
    - Add atmospheric scattering deferred script to camera (just like Unity Blacksmith setup)
    - Add atmospheric scattering sun script to directional light as sun.
    - Make sure shadow distance cover your scene (since the scatter occlusion depend on shadow)
    - Set Linear mode for realistic look

    Last, sorry for bad english and Title typo :(

    EDIT:add another version
    UPDATE: V 1.1 added, fix some calculation inconsistency
    UPDATE: V 1.2 fix mie black bug, sun mover script, and add realtime probe for better ambient lightning
     

    Attached Files:

    Last edited: Aug 17, 2016
    EMGPY, moure and mgear like this.
  2. Firedan1176

    Firedan1176

    Joined:
    Dec 7, 2013
    Posts:
    48
    That's so awesome. I might try it out layer :) Even better that it's free!!
     
    Ysgramor likes this.
  3. Ysgramor

    Ysgramor

    Joined:
    Jan 23, 2014
    Posts:
    69
    version 1.1 added, improve stability and fixed preetham calculation (more accurate)
    next update will be about outer space and night sky ( but dont expect fast update :D )
     
    Last edited: Aug 3, 2016
    looki666 likes this.
  4. paxilon

    paxilon

    Joined:
    Aug 9, 2016
    Posts:
    25
    Hey Ysgramor! Great Job! Really good to see it's shader independant!! Since I have no knowledge about writing shaders, would it be possible to bring back the Color adjustments to get more artistic control over the atmospheric scattering? (including world components, height and Mie color ramps like in blacksmith)

    Edit: Maybe you have the knwoledge to tell me how I can make the original blacksmith scattering tool Shader independant? Thanks in advance!
     
    Last edited: Aug 13, 2016
  5. Ysgramor

    Ysgramor

    Joined:
    Jan 23, 2014
    Posts:
    69
    @paxilon thanks, nice to see someone get advantage over this shader.
    can u explain more, what do you mean by independant? because current atmo shader from blacksmith already applicabe to other scene
    maybe u can give some details about what are you trying to achieve?

    for color adjusment, in this shader color adjusment no longer needed since the color already calculated by preetham formula.
    Thanks before
     
  6. paxilon

    paxilon

    Joined:
    Aug 9, 2016
    Posts:
    25
    Thank you for the Reply @Ysgramor! What I try to achive is that you don't need to use the Volund Shaders which where necessary to make the Atmospheric Scattering work. I plan to use other Shaders like the UBER Shaders and cool water shaders for environment. So to be independant from the Volund Scatter Shaders which you have to use on your objects and have maximum artistic control over color of the main Fog, Mie and Height Fog it would be awesome to use the Blacksmith Atmospheric Scattering globally. As you can assume I am an artist and have no idea about how to write or change shaders for my need :D

    Thank you so much in advance!
     
  7. Ysgramor

    Ysgramor

    Joined:
    Jan 23, 2014
    Posts:
    69
    Hi @paxilon the Blacksmith deferred scattering didnt need to use volund shaders, so you safe to delete shaders folder (2 vlound shaders, and 2 Unity cgnic)
    Dont forget to add atmo scatter deffered script in your camera to activate deffered scatter shader and set camera to deferred mode
    As far as i know, that volund scatter shader just for forward mode scattering.

    Feel free to ask here if u have some problem, im happy to help
     
  8. paxilon

    paxilon

    Joined:
    Aug 9, 2016
    Posts:
    25
    Omg :D This made my day. It was possible all the time. Thank you so much! Sometimes you need just that kind of hint. For more correct results I am definitely looking forward to use your version of the atmospheric scattering! Thanks!
     
    Ysgramor likes this.