   [cg] Vertex shader: problem with light specular component
  Hi everybody,I've got this problem when I use a CG vertex shader to illuminate one or more meshes:if the mesh is a box, one or two vertices of it appear white, but only if I rotate the scene in some particular positions. I haven't got this problem if the mesh is a sphere.I think it depends on some internal error (overflow??) when the shader execute the operations.As you can see in the code, the shader use 2 "dot" operator, 2 "normalize" operator and 1 "pow" operator. void GetDirectionalLightFactors(    float3    kModelPosition,    float3    kModelNormal,    float3    kCameraPosition,    float3    kLightDirection,    floatfSpecularExponent,    out float fDiffuseFactor,    out float fSpecularFactor){    float fDiff;    float fSpec = 0.0f;    float fZeroThreashold=0.0001f;   fDiff = -dot(kModelNormal,kLightDirection);    if (fDiff > 0.0f)    {float3 kViewVector = kCameraPosition - kModelPosition;if(abs(kViewVector.x) >= fZeroThreashold && abs(kViewVector.y) >= fZeroThreashold && abs(kViewVector.z) >= fZeroThreashold){kViewVector = normalize(kViewVector);    float3 kHalfVector = kViewVector - kLightDirection;if(abs(kHalfVector.x) >= fZeroThreashold && abs(kHalfVector.y) >= fZeroThreashold && abs(kHalfVector.z) >= fZeroThreashold){kHalfVector = normalize(kHalfVector);fSpec = dot(kModelNormal,kHalfVector);}}if (fSpec > fZeroThreashold)// && fSpec <= 1.0f)fSpec = pow(fSpec,fSpecularExponent);elsefSpec = 0.0f;    }   else   fDiff = 0.0f;  fDiffuseFactor = fDiff;    fSpecularFactor = fSpec;}  I think the error is giving by the pow function, which sometimes fails, but I'm not sure.Can someone help me? I hope I expose clealy the problem, if not post me a message for other details.Thank you   
  That's just the nature of per-vertex lighting.  The specular term for lighting is only high when the light reflects off the surface in the direction of the camera, which means you're only going to see it when one of the 6 vertices in your cube is  in the right position based on its orientation.  Since the specular term is being calculated per-vertex, you're not going to see anything even if part of the surface should be reflecting.  For your sphere, you probably have many more vertices so there's always a bunch where the reflection is visible.   