How to create a lens flare in Unity

Lens flare gives a decent look to your scene when you have the Sun visible. If you are an artist, you can create multiple lens flares with different texture. In this tutorial, we will learn how to create a simple lens flare for your Sun without the use of any custom texture.

I am using Unity 2021.1.13 for this tutorial.

Change your directional lights rotation so that the Sun is in the camera view.

By default, Unity adds a camera and a directional light to your new scene. If you move your camera around you must be able to see the Sun embedded into the skybox. The position of the Sun depends on the rotation of your directional light. We will be creating a flare as shown in the image below.

The first step is to create a flare asset.

You can do that by right clicking on the project window>create>Lens flare. If you are using URP or HDRP then select Lens flare (SRP).

Name the asset my_flare.

Select the texture as Flare texture. If you want a custom flare then you can use your own texture here.

Select 1 texture in Texture layout. If you have multiple textures then select this option accordingly.

Elements are the number of flares you want on your light. Let’s have one on the light which creates the bloom effect and three small ones a little away from the light. Enter the value as 4.

Before configuring the elements, we need to assign the flare asset to the light. So that we can see a live preview.

Go to your directional light settings in the inspector. You should see a Flare parameter in the light component.

Drag and drop your flare asset (My_flare) on to this.

Now go back to the My_flare asset and assign the following properties to the elements.

Element 0

Element 1

Element 2

Element 3

Now your final flare should look like the image in the beginning.

You can change the way it looks by changing the texture of the flare or you can download custom flare from the Unity assets store.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.