v9.1.1
Menu

Lambertian Reflectance Model

easyFREEPhotometric StereoPhotometryCV: 3D Reconstruction

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)

Output format: return the intensity as a number. Whenever the intensity is zero (for example n⋅l≤0\mathbf{n} \cdot \mathbf{l} \le 0), return the integer 0, so it prints as 0 rather than 0.0.

Example

Input
lambertian(0.8, [0, 0, 1], [0, 0, 1])
Output
0.8
Reasoning
  • Inputs: albedo ρ=0.8\rho = 0.8 means the surface reflects 80% of the incoming light. normal n=(0,0,1)\mathbf{n} = (0, 0, 1) points straight up out of the surface, and light_dir l=(0,0,1)\mathbf{l} = (0, 0, 1) points from the surface towards the light, also straight up.
  • Dot product: n⋅l=0⋅0+0⋅0+1⋅1=1\mathbf{n} \cdot \mathbf{l} = 0 \cdot 0 + 0 \cdot 0 + 1 \cdot 1 = 1. For unit vectors this is cos⁡θ\cos\theta, so θ=0∘\theta = 0^\circ: the light hits the surface head on.
  • Clamp: max⁡(0,1)=1\max(0, 1) = 1, so nothing is cut off here.
  • Scale by albedo: I=0.8×1=0.8I = 0.8 \times 1 = 0.8, the sample output 0.8. This is the brightest this surface can ever look, since cos⁡θ≤1\cos\theta \le 1.
  • Notice: if the light came from below, l=(0,0,−1)\mathbf{l} = (0, 0, -1), the dot product would be −1-1. The clamp turns that into 00, so a backlit surface is black, not negatively bright. A light along (0,1,0)(0, 1, 0) grazes the surface at 90∘90^\circ and also gives 00.

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

Learn this in

More from CV: 3D Reconstruction

solution.py

Test results

Sign in to run your code against the test cases.