Ray Tracer - Specular Highlights

Specular Highlight:
Specular highlight is the shiny spot that appears on the shiny surface when illuminated.

To calculate: 
If the direction of reflected light becomes equal to the direction of eye then we see a surface point P highlighted.

 Calculation:
reflectedRay = lightRay.direction - 2.0f * glm::dot( lightRay.direction, normal ) * normal;
float cosAngle = glm::max(glm::dot( eye.direction, reflectedRay ),0.0f);
float spec = powf( cosAngle, specularExponent) * dot(specularColor,currentMat.color);
 colors[index] += spec * lightcolor;








Image:

  

No comments:

Post a Comment