The specular highlight (labelled "specular" on the pictures you provided) is an specular reflection of the light source. It happens where the rays from the light source are reflected directly - with little or not scattering - into the camera.
For reflection, how light is scattered depends on:
- The material. In particular, how rough or smooth the surface is.
- The angle with the normal of the surface, respect to the position of the light and the camera.
Which means that whether or not a point is part of the specular highlight depends on:
- The normal of the surface on the point.
- How rough or smooth the surface is on the point.
- The direction to the light source from the point.
- The direction to the camera from the point.
Let us come up with some names.
Let us say we are considering a point
P which is on the surface of the object. And we would do this for every visible point, but we are going to consider one point at a time.
And let us say the normal at the point
n. I'll be assuming that
n is a unit vector (a vector of length
Let us say the light source is at position
S. And the camera is at position
So the position of the light source relative to the point is
S - P. And thus the direction of the light from the point is:
l = normalize(S - P)
Which is equivalent to:
l = (S - P) * 1/length(S - P)
* denotes scalar product. So we are scaling the vector
S - P by the inverse of its length. Which gives us a unit vector in the same direction.
Similarly, the position of the camera relative to the point is
C - P. So the direction of the camera from the point is:
v = normalize(C - P)
Which is equivalent to:
v = (C - P) * 1/length(C - P)
By the way,
norm, which is also represented with vertical bars
|) would be the Pythagoras' theorem. It extends naturally to 3D like this:
length = sqrt(x*x + y*y + z*z), where
sqrt is the square root.
Now, the question is how close direction to the camera from the point compared to the ideal reflection direction. And whether or not it is close enough to be an specular highlight.
This picture is taken from the article: Warp3D Nova: 3D Lighting - Part 1 by Hans de Ruiter.
We can compute the ideal reflection direction
r starting with the direction to the light
l, and the normal
n. Such that the incident angle (the angle between
n) and the reflection angle (the angle between
n) are equal.
With the formula for vector reflection (under the assumption that
l are unit vector) we have:
r = n * 2(l·n) - l
· denotes dot product.
Then we can ask what is the angle between
angle = angle_between(r·v)
Which we can compute using the inverse cosine function (
acos) and the dot product (under the assumption that
V are unit vectors).
angle = acos(r·v)
I have explained the relationship between cosine and the dot product on my answer to "When are oblique triangles used in game development?". You may also be interested in How to Work With Arbitrarily Oriented Vectors.
Finally there will be some
max_angle which depends on how smooth the surface is. And the point is in the specular highlight if
angle < max_angle.
Well, actually, that is a simplification. In reality, it is not that there is a
max_angle. It is that the intensity of the reflection decays with the
angle until we disregard it. And how fast the intensity decays with the angle depends on how smooth the surface is.
You can confirm in the photos in question that area near the specular highlight is also bright, just not as much.
Varying roughness (from left to right, rough to smooth). This picture is taken from the article Physically Based Rendering in Filament.
This is because a rough surface does not reflect all the incoming rays in the same direction. Roughness here would be a representation of micro-imperfections in the surface.
A systematic illustration of light scattering at a randomly micro rough surface. This picture is taken from the scientific article Matt Polyurethane Coating: Correlation of Surface Roughness on Measurement Length and Gloss.
Instead of simulating the micro-imperfections of the surface, we encode them as macro properties of the material (such as roughness) which characterize the behavior of the light reflecting on it. We need to consider how realistic we want to generate the pictures, and also how computationally expensive is it to do it. In particular in video games, where we have a limited time to generate each frame.
About the situation depicted in the photos in question is that for the position of the light, the position of the camera, and the position, orientation and geometry of the object. There might be some point or points that get a very intense specular reflection, and we call that a specular highlight.
And if we change any of those variables (the position of the light, the position of the camera, and the position, orientation and geometry of the object) the set of points that get that very intense specular reflection is going to be different.
Thus, translating or rotating the object changes what points have the specular highlight. And so does moving the camera, or moving the light source.
Let us consider the situation where only we moved the camera.
The object and the light source remain in the same place. Thus the angle of the incident light is the same for every point. However, in one position of the camera some points reflect into the camera at the ideal angle. And in the other position, some different set of points reflect the light into the camera at the ideal angle.
To put it in the terms defined above. If we don't move the object or the light source then for every point
l remain the same, and thus
r also remains the same. However, if we moved the camera then
v would change. So, in one position of the camera some points have a very small angle between
r. And in the other position, some different set of points have a very small angle between
r. As a consequence we see the specular highlight in a different place.