Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Lens Flares - not showing / behaving strange

Discussion in 'Editor & General Support' started by LOG3, Jan 5, 2011.

  1. LOG3

    LOG3

    Joined:
    Jan 5, 2011
    Posts:
    6
    EDIT: Hoping to bump this up as this is a real annoying bug. Tried it on another PC and still buggy. The Lens Flares just behave how they want. If I add a 2nd Lensflare to the scene and hide the old one, sometimes I get one to appear by disabling/enabling them or updating them otherwise.
    Still they will only appear in either scene OR game view OR while running... as this is kind of urgent I hope to get some help from here. Hopefully I am not overseeing some trivial thing ;(


    Hey, so this might be a bug, anyway I hope someone can help me out because this is bugging me the whole time.

    Lens flare (also Halos) in general are not showing, neither in the inspector nor while running.

    The Idea is to create a sun with a lens flare.
    I did a very basic setup by creating a new project - importing everything and setting up a scene like this:

    1. Added a skybox texture to the Main Camera via Edit->RenderSettings (Flare layer is checked)
    2. Created a standard sphere
    3. Attached a lens flare component to the sphere
    4. Choosed a lens flare (50mm Zoom)

    The funny part now happns while I run the scene:

    On the lens flare component, whenever I check the "Directional" box and uncheck it again
    the lens flare appears but vanishes again (shrinking until it disappears) in the same second.

    After this If I stop it and check/uncheck the directional box in the game-view the lens flare magically appears! (But is still missing in the scene-view. FX effects are on)
    But any changes on the lens flare makes it disappear again and the only solution is to check/uncheck the directional box again.

    Also this method did not always work. Now all the lens flares are gone forever and won't show up even with the check/uncheck method.

    Creating a new scene like mentioned above not only reproduces this but I also get the following error messages over and over.
    EDIT: They appeared after attaching the lens flare (Step 3):


    --------------------------------------------
    !IsNormalized (dir)
    UnityEditor.DockArea:OnGUI()

    !IsNormalized (ray.GetDirection ())
    UnityEditor.DockArea:OnGUI()

    Scene::raycastAnyShape: The maximum distance must be greater than zero!
    UnityEditor.DockArea:OnGUI()
    -------------------------------------------

    I am using Windows Vista 64-bit with Unity free v 3.1.0f3 (54715)

    Looking forward to hear from you :)
    Greetz, LOG3
     
    Last edited: Jan 6, 2011
  2. LOG3

    LOG3

    Joined:
    Jan 5, 2011
    Posts:
    6
    Seems I've found a solution.

    I guess the problem was that I attached the light/sun flare to the sphere.
    Therefore it wouldn't show because it was 'inside' the sphere.

    Changing the spheres layer to 'Transparent FX' made it buggy. Guess the sunflare was somehow ignoring itself then...

    Now I created a light with a sun flare seperately and positioned it in the center of the sphere.
    Works! yay :)
     
    Last edited: Jan 7, 2011
  3. Taugeshtu

    Taugeshtu

    Joined:
    Apr 2, 2011
    Posts:
    21
    Unity 3.0.0f5 - and I've got the same bug - REALLY annoying!
    And there's no point if there is anything between cam and Lens Flare object or not - it just has mind of its own. Witchcraft...
     
    Last edited: Apr 14, 2011
  4. wkmccoy

    wkmccoy

    Joined:
    Jul 6, 2010
    Posts:
    29
    One thing I had to learn, was that a Collider can cause the player to not see the lense flare, so if you have a Collider around your player to trigger stuff, you have to make sure its not around the camera. (ie camera is inside the collider) Also the Camera has to have a lense flare on it as well as it being checked on the light source (I use the light source to simulate the sun doing this)
     
    exorakhilas likes this.
  5. Lex-DRL

    Lex-DRL

    Joined:
    Oct 10, 2011
    Posts:
    139
    We (our team) had the same problem with lens flares: they was unpredictibly disappearing. This "bug" even appears from time to time in absolutely clean project, in absolutely clean scene. The worst thing here is that you never know when it will render and when it won't. There was times when if you start unity once, flares are not visible, and if you restart unity, they are displayed as should. Yes, completely unpredictable behavior.

    We tried everything. And looks like we found the source of this problem and therefore it's solution:
    • In the object that has "Lens Flare" component, make sure that under "Ignore Layers" "Default" layer (or whatever layer your lens flare object itself is at) is NOT selected. The above problem appears only if you try to ignore the layer your flare is at.
    • Also, you should create new empty object, add "Lens Flare" component to it and parent it to some other object, rather than adding component to that "other" object directly. And that's why: if you add this component to the object that has any collider, you'll need to set it's layer as ignored. And if you do so, than the layer that lens flare is at is ignored, and then you have troubles I described. The only objects that you can add Lens Flares directly at are lights. If they don't have any collider, of course.

    I've posted it here just to help anyone having this trouble.

    P.S.: IMHO, it is a bug that Lens Flare behaves unpredictably if the layer it is on is selected in "Ignore Layers". The fact that you can fix it with native tools is good, but it's still a bug.
     
    astracat111 and Dev5DT1 like this.
  6. Cornotiberious

    Cornotiberious

    Joined:
    Dec 5, 2012
    Posts:
    6
    I'm not quite tech savvy enough to fully grasp what you are saying. Yesterday I loaded up my game and everything was fine, today after absolutely NO CHANGES were made, the flares do not work, but only for that specific game. If I pull up a new project or any other project at all, Flares work perfectly. The flares worked perfectly yesterday before I closed the game and today they do not show up no matter what I do.
     
  7. Lex-DRL

    Lex-DRL

    Joined:
    Oct 10, 2011
    Posts:
    139
    Try to do what I described. This "layers stuff".
     
  8. Bren

    Bren

    Joined:
    Aug 28, 2008
    Posts:
    191
    I've found they don't work in the Game view unless the Scene view has the little "Light" button turned on.
     
  9. Cornotiberious

    Cornotiberious

    Joined:
    Dec 5, 2012
    Posts:
    6
  10. exorakhilas

    exorakhilas

    Joined:
    Jan 30, 2013
    Posts:
    4
    Thank you, you are right. Colliders somehow block the light flares.

    Here, have some pikachu pumpkin and have a nice day :D
     
  11. ronaldodalan

    ronaldodalan

    Joined:
    May 10, 2015
    Posts:
    1
    Thank you! I was going crazy with a similar problem!
     
  12. gregroberts

    gregroberts

    Joined:
    Nov 21, 2014
    Posts:
    25
    we had *precisely* this problem and behavior (fast fade only upon checking "Directional" during runtime).

    SOLUTION :
    1. select the Lens Flare itself (in our case, 50mm) in the Project pane.
    2. Look in the Inspector for the Flare.
    3. UNcheck "Use Fog"

    BOOM. Solved.
     
    astracat111, AlexanderL1 and Peter77 like this.
  13. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    BOOOM!! you're right!!!!!!!!!!!!!!!!!!! tx!!!!!!!!!!!
     
  14. brookiechookie

    brookiechookie

    Joined:
    Jul 18, 2021
    Posts:
    1
    Unfortunately none of these solutions worked for me, probably since I'm in a newer version. My solution was to go to my camera object, select component --> Rendering --> Flare Layer. This then added a flare layer to the camera and it then worked in game view! Hope this helps someone with the same struggle.
     
    ZerglingV and Gabo_campitelli like this.
  15. Krnitheesh16

    Krnitheesh16

    Joined:
    Apr 22, 2020
    Posts:
    9
    Adding "Flare Layer" to Camera Object and Enabling "Post Processing" in Camera Component worked for me.
     
  16. Roxanna20

    Roxanna20

    Joined:
    Sep 14, 2020
    Posts:
    2
    hello everybody. I did everything what you all said. still not working. its a bug. Maybe with URP doesnt work??
     
  17. Roxanna20

    Roxanna20

    Joined:
    Sep 14, 2020
    Posts:
    2
  18. astracat111

    astracat111

    Joined:
    Sep 21, 2016
    Posts:
    699
    Lens flare not showing up in game for me, I'll update when I fix it.

    Right now it's your typical nightmare scenario for me: Works in editor playtesting, not when game is built.

    I've always had strange behaviour with standard post processing effects, they always seem to come out different when a game is built vs in the editor. When dealing with post processing, it's a good idea to check what settings work I guess in a smaller project, make sure you check what post processing fx look like when the game is built, not just playtesting in the editor.

    My guess?

    It's a shader problem or conflicting shaders, that is sometimes you have one shader blocking another. It gets complex, might be the 'depth of field sphere' I created, might be fog conflicting with it, etc etc...