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 Phong specular contribution of a single light.

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

where l is the unit direction from the surface toward the light, n the surface normal, and v the unit view direction from the shaded point toward the eye. A thin wrapper over [phong_specular_term], so a direct call and the same light routed through LightingUniforms::shade_with_visibility share one implementation.

§Arguments

  • &Light - The light source. Its direction must point from the surface toward the light.
  • 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.