Skip to main content

compute_phong

Function compute_phong 

Source
pub fn compute_phong(
    light: &Light,
    normal: Vector3D,
    view_dir: Vector3D,
    material: &Material,
) -> Vector3D
Expand description

Computes the Blinn-Phong specular contribution of a single light.

Returns:

light_color * intensity * pow(max(0, dot(reflect(-l, n), v)), shininess) * specular

where reflect(-l, n) is the mirror reflection of the light direction about the surface normal and v is the unit view direction from the shaded point toward the eye.

§Arguments

  • &Light - The light source.
  • Vector3D - The surface normal (unit length).
  • Vector3D - The unit view direction (from the surface toward the eye).
  • &Material - The material at the shaded point.

§Returns

  • Vector3D - The specular contribution of this light.