diffuse_intensity = normal dot light_dir
= normal.x * light_dir.x
+ normal.y * light_dir.y
+ normal.z * light_dir.z
R = diffuse_intensity * light.red * material.red
G = diffuse_intensity * light.green * material.green
B = diffuse_intensity * light.blue * material.blue
(light.red is the red value of the GL_DIFFUSE color of the light source, etc.)