Search Unity

Sun halo effect

Discussion in 'Shaders' started by chris-z562, Jul 26, 2015.

  1. chris-z562

    chris-z562

    Joined:
    Jul 11, 2012
    Posts:
    41
    Hi, I'm trying to achieve this effect



    The effect is a part of a sky explained a bit here: http://blog.camposanto.com/post/112...-detail-explanation-of-part#livefyre-comments

    I figure it's a good idea to use a sky sphere (instead of box). I give the shader a sun vector that corresponds to the position of the sun. I can compare this with the normal in the shader to see if they're close. So getting a completely round sun is fairly simple. The problem lies in getting the sun to glow towards the horizon.

    Some video of the effect as well (at 8m50s):
     
  2. borbs727

    borbs727

    Joined:
    Jan 9, 2018
    Posts:
    8
    I'm also curious how to achieve this effect (in unreal or unity). I instantly thought of metaballs when I was brainstorming some things to search and came across this video that explains some of the concepts and math behind blending:
     
    Last edited: Aug 5, 2019
  3. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    I implemented something very similar, to fake atmospheric scattering and create more vivid sun rises/sets.

    What I did was to create a mask of the horizon (A), representing a soft thick white line over the horizon. And a large soft gaussian shape (B) at the sun's position. Then multiply those together. When B moves towards the horizon, more of A starts the show, but limited to the shape of B (due to the multiply operation). All in all, this starts to represent a haze:

    (Ignore the per-vertex sun disk, I'm not using one but added it for this example)

    Graph in Amplify Shader Editor for a logical view:

    upload_2019-8-5_9-43-34.png
    As I mentioned, the "hard sun disk" section can be left out
     
    danilonishimura likes this.