Rendering a geometry with a fragment specular lighting
Specular lighting allows us to add bright highlights or reflections on the surface of a model. This way rendered geometry looks shinier and more glossy.
An example of an image generated with this recipe looks like the following:

Getting ready
The most commonly used algorithm describing the way surfaces are lit is a Blinn-Phong model. It is an empirical model, which isn't physically correct but gives results that are more plausible in situations where rendered geometry is simplified. So it is well suited for 3D real-time graphics.
The Blinn-Phong model describes light leaving a given surface as a sum of four components:
- Emissive: The amount of light emitted by the surface
- : The amount of reflected light that is scattered around the whole scene and doesn't have any visible source (used to brighten up the geometry)
Ambient: The amount of reflected light that is scattered around the whole scene and doesn't have any visible source (used to brighten...