A basic diffuse lighting algorithm lies at the core of most lighting calculations. It is used to simulate the appearance of matte surfaces that reflect the light, scattering it in many different directions. In this recipe, we will see how to achieve geometry rendering using vertex and fragment shaders that implement the diffuse lighting algorithm.
An example of an image generated with this recipe looks like the following:

The following recipe is very detailed so that you can understand and follow all the steps more easily. Further recipes will be based on the knowledge described here, so they are shorter but also more general.