Specular

The specular term provides mirror-like reflections. Conceptually, the specular reflection reaches its maximum when we look at the object at an angle that is equal to the reflected light-direction vector.

The specular term is modeled by the dot product of two vectors, namely, the eye vector and the reflected light-direction vector. The eye vector originates in the fragment and terminates in the view position (camera). The reflected light-direction vector is obtained by reflecting the light-direction vector upon the surface normal vector. When this dot product equals 1 (by working with normalized vectors), our camera will capture the maximum specular reflection.

The dot product is then exponentiated by a number that represents the shininess of the surface. After that, the result is multiplied by the light and material specular components:

Where:

is the final specular color,  is the light specular color,  is the material specular color, and n is the shininess factor.

That being said, we'd derive the final specular color with the following:

If R and E are normalized, then:


It's important to note that the specular reflection reaches its maximum when R and E have the same direction.

Once we have the ambient, diffuse, and specular terms, we add them to find the final color of the fragment, which provides us with the Phong reflection model.

Now, it’s time to learn about the language that will allow us to implement the shading and lighting strategies inside the vertex and fragment shaders. This language is called ESSL.