Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // InfLight Specular
- else if(light_iterator->getType() == "infLight"){
- Vector3D l = Vector3D::normalise(light_iterator->getLdVector());
- double cosAlpha = n.x * l.x + n.y * l.y + n.z * l.z;
- if(cosAlpha > 0){
- Vector3D r = Vector3D::normalise(2* cosAlpha * n - l);
- Vector3D p_eye = -Vector3D::vector(x_3d, y_3d, z_3d);
- p_eye.normalise();
- double cosBeta = r.x * p_eye.x + r.y * p_eye.y + r.z * p_eye.z;
- if(cosBeta > 0){
- double reflection_factor = pow(cosBeta, reflectionCoeff);
- specRed += specularReflection.red * light_iterator->specularLight.red * reflection_factor;
- specGreen += specularReflection.green * light_iterator->specularLight.green * reflection_factor;
- specBlue += specularReflection.blue * light_iterator->specularLight.blue * reflection_factor;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement