Lighting can add certain dynamics into your 3D scene or game, which can make it more immersive. Everything you see is a light that reflects from surfaces. Some part of the visible light is absorbed by the material on a surface. The rest of the visible light spectrum defines the material color. You can say that the surface material reacts with the light in a certain way. Therefore, OpenGL attributes light processing into parts—material and lighting.
OpenGL tries to approximate light distribution and reflection by five material attributes, which are as follows:
GL_DIFFUSE
: This specifies the color of the surface and is mostly the attribute you will want to useGL_AMBIENT
: This affects all vertices equally and often simulates ambient lightGL_SPECULAR
: This is the color of the highlightGL_EMISSION
: This is the emitted light color, which can be used for surfaces that emit light, such as lamps or LEDsGL_SHININESS
: This specifies the size of the highlighted area; smaller...