Lens flare
As mentioned in some of the recipes of Chapter 4, Postprocessing, some of the techniques we covered copy qualities common to a camera lens instead of a human eye. Lens flare is yet another camera lens imperfection commonly seen in movies. Usually seen when a very bright light source is present (such as the Sun), lens flare shows up as a series of colorful shapes that cover the scene. As an example, the following screenshot showing the Sun close to the top-right corner and a series for lens flares spread over the screenshot's diagonal:
For this recipe we are going to generate lens flares only for the Sun. This implementation can be easily modified to support other light sources. See the There's more... section for additional details.
Getting ready
For this example we will be adding lens flares only for the Sun. See the There's more... section for details about extending the support to other light sources.
Before we start rendering the lens flares, we will need to decide if the light...