This sample shows you how to implement a lens flare effect by using occlusion queries to detect when the sun is hidden behind the landscape.
Sample Overview
The graphics technique called "lens flare" tries to simulate how bright lights behave when they shine into a film camera. Computer games often have a hard time conveying an impression of brightness because monitors and televisions have only a limited range. After all, it is impossible to have a pixel brighter than white. How can you show the difference between a character wearing a white t-shirt, which is not very bright, and the sun, which is very bright indeed? The solution is to emulate what happens when a movie director points a camera directly at a bright light source. Games can emulate the flares that would be produced inside a physical camera. The flares provide a visual cue that indicates the brightness of the light.
The lens flare effect in this sample is formed of two components: a large, soft glow, plus a row of smaller circular flare shapes.
The sample uses hardware occlusion queries to efficiently detect when the sun is hidden behind the landscape. This enables you to fade out the lens flare effect when the sun is not visible.