- Home /
Lens flare - wrong behaviour
Hello, as the title says I'm experiencing a weird behaviour with the lens flare component. Basically I have 2 issues: 1 - big colliders (e.g. planets), at a certain distance, stop occluding the flare. 2 - when moving (interpolated rigidbody), the occlusion is not smooth... it looks flickering. The 2 videos below eplain it better. Am I the one experiencing these issues? Any ideas to get them fixed? They're driving me nuts. Thank you in advance. Video: flare and collider issue - Video: flickering flare
Answer by VicciGames · Nov 22, 2019 at 03:30 AM
would try using a smaller size of units.*
Currently, I am witnessing a x10000 scale than normal. Which is HUGE. I am almost positive the post-processing layer has some sort of unit limitation or distance limitation.
If you scale to 1/1000 to get a size of 100 for the object, your flickering problem should be solved.
You can still work with a smaller scale, just be respectful with your Physics calculations and use FixedUpdate when possible to adhere to FPS scaling.
Let me know if this worked.
Scaling works. As I said, I'm still sure it's a wanted (then coded) behaviour, like a distance limit: beyond that limit, lens flare stops getting occluded. I would still like to know how to alter/modify that behaviour.
Regarding the flickering issue, I can confirm it's nothing related to scaling. If the occluding object (in this case, the player's ship) is a rigidbody and its movements are interpolated, when it slowly reaches the "source" of the lens flare (a 1x1 point), the engine doesn't exactly know if it is occluding that point or not (unless it's covering it with a bigger part of its shape). Without interpolation, the occluding object's position is exactly defined so it is definitely occluding (or not) the point source of the lens flare: in this case, the flicker doesn't occour.
I'm surprised nobody spotted this obvious behaviour (or talked about it) before: I don't think I'm the only one using rigidbodies with interpolation + lens flare.
A little update on the 2nd issue (flickering flare): I finally dropped interpolation and made the un-interpolated rigidbody look smooth by lowering the fixed timestep to 0.01667, so now everything running in FixedUpdate updates 60 times per second. Interpolated movements AND lens flare don't get along.
Answer by U2-84 · Nov 22, 2019 at 10:01 AM
Hi @VicciGames, thanks for your reply. I'll try it and let you know as soon as I come back home, but I'm sure it will work. I think it's a distance problem, more than size. The same huge sphere occludes the lens flare perfectly when it's about <6500-7000 units far from the camera. Scaling everything, I'll shrink sizes and consequently distances, so it should work.
I am wondering: what if it's a wanted behaviour? I mean: very distant colliders should not occlude the lens flare (imagine a very tiny asteroid, far far away, so far that you can't even spot it. Would be weird to see the flare hiding for no reason... But we know that the flare is centered on a single pixel point (1x1), so even the smallest distant object might occlude it. I think they voluntarily designed it to avoid occlusion from little distant objects). So there must be a "distance" variable somewhere that enables or disables flare occlusion. Maybe in the lens flare script? If so, how can I access the built-in lens flare script?
Talking about the 2nd issue (the flickering flare when I slowly occlude it), I think it's not related to sizes or distances. If you look at the video, it flickers only when the occluding object (player ship) is moving - changing coordinates. If I stop moving and I just rotate (in the video, you can see when I move forward because there's "space dust" floating around me), the flare hides smoothly. This strange behaviour only occours if interpolation is enabled on the rigidbody. Without interpolation, everything works fine (but I don't want to drop interpolation... I like how it smooths the overall movements. Without interpolation, there's a constant "micro-stuttering / jitter" that makes the game look like it's running at 30fps even if it's 100+).
Your answer
![](https://koobas.hobune.stream/wayback/20220612215136im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
physics.OverlapSphere colliders 1 Answer
Blender Meshes not colliding Unity 4. 1 Answer
Terrain not generating tree colliders 4 Answers
Issues scaling a object with children colliders 1 Answer
Load a level at a specific point 1 Answer