The perceived color of a surface due to diffused reflection, which we call I, is computed with the Phong Illumination Model
I = M*L*cosine(A)
where M is the material color and L is the color of the light source (omni or directional in this tutorial). A is the angle between the vertex normal (N) and the vector (V) pointing to the omni position or parallel but in the opposite direction in the case of a directional light. Although the range of values for the cosine function is 1.0 to -1.0, cosine(A) is clamped between 1.0 and 0.0. Note that the formula for I is similar to that used for ambient reflection except for the factor cosine(A) (see the tutorial on ambient reflection).
The calculation for I is done for each of the color components red, green and blue. Also, the calculation is done for each light source and the final illumination value is the sum of the computed results. However, the final value for each color component is clamped between 0.0 and 1.0. This means that I can never be less than 0, which would be the case when the angle A is bigger than 90 degrees. Also, if ambient light is present, the color values computed from the ambient reflection formula are added. Again, the final result is clamped between 0.0 and 1.0.