const Vector3 viewDir = -ray.d; // d is a unit vector
I don't think ray.d is normalized as well.
You seem to be contradicting the comments in your own code.
Sorry. Most of that code was given to us by the lab assistant, and I didn't notice it
I meant specular light, not diffuse, my bad again.