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

Sun Flare?

Discussion in 'Scripting' started by Zenov, Sep 19, 2014.

  1. Zenov

    Zenov

    Joined:
    Jul 28, 2014
    Posts:
    53
    Hi all,
    I currently have a day/night cycle in my game and I'm using a flare for my sunlight. The problem is the flare disappears behind objects. I don't want the flare to shine through the objects but I would like it to stay visible behind the object. Is that possible? I'm trying to make a realistic sun. How should I approach this?

    example of what I mean:

    (a flare would completely disappear in this case)

    Thank you



    (Edit: I'm not sure if coding would be required for this, so please move this thread to the appropriate place if needed. Thanks)
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I think you may be confounding two different effects here. A lens flare does disappear when the light source that's flaring is obscured. Unity's lens flares are realistic in this sense.

    However, there's also atmosphere scattering of the sun's light, which creates a halo. A halo's different from a flare, and has nothing to do with lenses. The halo should remain.

    So, paint the halo into your sun texture, and it will show around the sun in the case above. Also add a lens flare, and let it disappear (as it should).
     
  3. Zenov

    Zenov

    Joined:
    Jul 28, 2014
    Posts:
    53
    Interesting. The tutorial I was following for creating the effect only used a flare with no mesh. I tried using a halo but nothing showed up (probably because it has no mesh). I'll try adding a mesh and halo. Hopefully that will fix it. Thanks for your advice :)