Skip to main content

compute_lambert

Function compute_lambert 

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

Computes the Lambertian (diffuse) contribution of a single light at a shaded surface point.

The returned color is computed as:

color * intensity * max(0, dot(normal, light_dir)) * albedo

For directional lights, light_dir is the unit direction toward the light. For point and spot lights, light_dir is the unit direction from the surface position to the light position. The light’s color and intensity are merged multiplicatively with the Lambertian cosine term and the material’s albedo. The caller is expected to have already applied any falloff factor.

§Arguments

  • &Light - The light source being evaluated.
  • Vector3D - The surface normal (expected to be unit length).
  • &Material - The material at the shaded point.

§Returns

  • Vector3D - The diffuse contribution of this light.