Free Realime Atmospheric Scattering Based on Unity Blacksmith

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 :smile: and Im not good at math and caclculation, maybe some wrong calculation happen here :roll_eyes:
I hope someone whose expert at shader can optimize this shader.

Suggestion and bug report much apreciated.

Screenshots

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 :frowning:

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

2733556–196098–Realtime Atmospheric Scatter Sky V 1.2.unitypackage (1.54 MB)
2733556–196099–Realtime Atmospheric Scatter Sky V 1.2.7z (1.37 MB)

3 Likes

That’s so awesome. I might try it out layer :slight_smile: Even better that it’s free!!

1 Like

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 :smile: )

1 Like

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!

@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

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 :smile:

Thank you so much in advance!

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

Omg :smile: 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!

1 Like