PIXELBANKv9.1.0
Menu

Lambertian Reflectance Model

Compute the observed intensity under Lambertian (diffuse) reflectance.

The Lambertian reflectance model describes how light reflects from matte surfaces:

I=ρ⋅max⁡(0,n⋅l)I = \rho \cdot \max(0, \mathbf{n} \cdot \mathbf{l})

where:

  • II is the observed intensity
  • ρ\rho is the surface albedo (reflectance) in range [0, 1]
  • n\mathbf{n} is the unit surface normal vector
  • l\mathbf{l} is the unit light direction vector
  • The dot product is clamped to non-negative (surfaces facing away get no light)

Key properties:

  • Intensity is maximum when n=l\mathbf{n} = \mathbf{l} (light directly overhead)
  • Intensity decreases as angle between normal and light increases
  • Intensity is zero when angle exceeds 90° (backlit surface)

Example:

Input:
lambertian(0.8, [0, 0, 1], [0, 0, 1])
Output:
0.8
Reasoning:

Surface facing directly into light: dot(n, l) = 0×0 + 0×0 + 1×1 = 1.0

  • I = 0.8 × max(0, 1.0) = 0.8 Maximum intensity when normal equals light direction.

Constraints:

  • albedo: surface reflectance in range [0, 1]
  • normal: unit surface normal [nx, ny, nz]
  • light_dir: unit light direction [lx, ly, lz]
  • Return intensity clamped to non-negative
solution.py

Test Results

0/0
Run code to see test results.