What's the trick to getting Lens Flares working?

It just doesn’t seem to want to work. Do I have to set the lighting a certain way? Here’s the spot light I’ve attached the lens flare to and the settings:

Maybe you have removed the Flare Layer from the camera by accident? Lens flares only show up in the cameras with flare layers (by default a camera has one).

Or maybe the Flare Strength in the Render Settings is low?

Nope, the camera has a Flare Layer.

I checked, Flare Strength is set to 1, the maximum.

The only objects that might be blocking this are the stack of cones I’m using to simulate the “volumetric light”. So I set all these to the “TransparentFX” layer, still doesn’t work.

If you are looking at it in the scene view, you need to click on the fx button to see it.

In game view they always show up. (Provided you didnt remove the Lens Flare Layer from the camera)

You also want to have the lens flare only once. (Remove the Lens Flare component, dragging the 50 mm zoom on the light flare property is enough)

Are you trying to get them to work on a secondary camera? Because that is the problem I am having.
I’m not ignoring the Flare layer, the top camera has the Sun Flare Layer as well as the bottom. I know that they are the same, because I duplicated the bottom camera! I can’t seem to figure it our either. Do certain Graphics cards not support this? Is it a funky limitation of OpenGL?

19068--622--$sun_flare_problems_828.png

Thanks Joachim, I think this was part of the problem. I tried fixing the settings but it didn’t work, so I just deleted the old spotlight and camera and inserted new ones. Now it works but something “wierd” is happening. The lens flare seems to be -blocked- by something in the scene even though there’s nothing there.

The first screen is what it looks like when the light is far away from the vehicle, the flare appears properly. But if I move the light towards the vehicle the flare becomes “blocked”. What’s wierd is that there isn’t any mesh to block the light at that position? How does Unity calculate this and how can I fix this?

Thanks!

We are using colliders for calculating the flare blocking. So if your mesh has a primitive collider eg. a box collider maybe it is a little too large?

A-Ha! That’s what I suspected! I was just about to test this theory when I got your reply, thanks! Yes, I’m using a simplified box collider for the entire vehicle at the moment. The vehicle is made of separate objects, so I assume (haven’t tried this yet) I can create a collider mesh for each object. That should fix it, I’ll give it a try.

If you have an object which you are moving around with a rigidbody, then thats not a good idea. If it’s just static geometry, shouldn’t be a problem.

Uh-oh. That’s exactly what I’m doing. Right now the entire vehicle is using one box collider, but I was hoping on using 2-3 for the “body” of the vehicle and another 3 for the “grab arm”. I can’t do that? How do you work around this?

You usually just build the collision hull out of multiple primitive colliders. A couple of boxes, spheres, capsules. They just need to be children of the rigidbody, then they will automatically be treated as a compound primitive collider.

Ok, I’ll do some homework on this. Not sure how to set this up in Unity yet. My thought was that using 5 or 6 box colliders would be more efficient/faster than using the “mesh” collider, yes? And speaking of mesh colliders, are they “dynamic”? In other words, if I assign a mesh collider to an object and then later morph the object or move an element of the object, is the mesh collider physics smart enough to handle this? I don’t plan on doing it this way, just curious.

You can move, rotate, scale colliders at runtime without problems.

Yes, a couple of small primitive colliders are always more efficent than mesh colliders.

If you ever do want to use a mesh collider for a rigidbody, I’ve found that it works well if your mesh is made of a single contiguous skin with no open areas or other non-manifold vertices, and all normals pointing outward. Otherwise wonky things can and will happen. Efficiency is another matter though…typically you’d be better off with primitive colliders.

–Eric

Thanks Eric. I will be creating a mesh terrain for this sim and the mesh collider would be the best solution for that I think.

The general being of course:
Level/static geometry that is not attached to a rigidbody can be and most often should be mesh colliders. Rigidbodies should be primitive colliders.

Argh… the lens flare is still not behaving properly. It appears as the object turns left and right, but if I move it up and down the flare disappears as the viewer aproaches the focal point. I’ve moved all objects (with colliders or not) away from the light and tried it with the light source even far away from the vehicle, still the same. I still have some things I can try, but this is pretty strange.

You probably still have some colliders setup too large. You can easily see them by pressing cmd-a (Select all). All primitive colliders are visualized with a blue outline.

Nope, even happens when I have -no- colliders in the scene… :frowning: