Advertisement
Guest User

Untitled

a guest
May 22nd, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. // InfLight Specular
  2. else if(light_iterator->getType() == "infLight"){
  3. Vector3D l = Vector3D::normalise(light_iterator->getLdVector());
  4. double cosAlpha = n.x * l.x + n.y * l.y + n.z * l.z;
  5. if(cosAlpha > 0){
  6. Vector3D r = Vector3D::normalise(2* cosAlpha * n - l);
  7. Vector3D p_eye = -Vector3D::vector(x_3d, y_3d, z_3d);
  8. p_eye.normalise();
  9. double cosBeta = r.x * p_eye.x + r.y * p_eye.y + r.z * p_eye.z;
  10. if(cosBeta > 0){
  11. double reflection_factor = pow(cosBeta, reflectionCoeff);
  12. specRed += specularReflection.red * light_iterator->specularLight.red * reflection_factor;
  13. specGreen += specularReflection.green * light_iterator->specularLight.green * reflection_factor;
  14. specBlue += specularReflection.blue * light_iterator->specularLight.blue * reflection_factor;
  15. }
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement