Change Lighter position but the combined lighting does not change

Hi there,
I am doing the tutorial of opengl. I have an interesting problem.
The lighter position sames like does not affect the lighting effect of lightened object. I find that even for the rear surface, there is still diffuse and specular effect. According to calculation in fragment shader, the diffuse and specular is functioned by the reflect direction, and normal vector. For the situation that the lighter is behind the surface, it using the max function return 0 because now the dot product is negative. So it means the diffuse and specular are vanished. However, they still exist.

The fragment shader about diffuse and specular:

vec3 norm = normalize(normalVec);

//diffuse
vec3 lightDirection = normalize(light.position - FragPos);
float diff = max(dot(norm, lightDirection), 0.0);
vec3 diffuse = light.diffuse* (diff*material.diffuse);

//specular	
vec3 viewDirection = normalize(cameraPos - FragPos);
vec3 reflectDirection = reflect(-lightDirection, norm);
float spec = pow(max(dot(viewDirection, reflectDirection), 0.0), material.shininess);
vec3 specular = light.specular* (spec* material.specular);

Is there someone know how this problem can be solved? I was also tried that change the lighter position as time runs by, however the diffuse and specular are not variation.

Thanks for your help


Well I found that, if the surface is parallel with lighter even my camera is behind the surface, the diffuse and specular always working, but if the surface is side (by 90 degree) the diffuse and specular are disappear. :frowning: