---
id: "photometric-stereo"
title: "Photometric Stereo"
aliases: [shape from shading, multi-light]
domain: "capture"
stage: "capture"
realtime: "offline"
platforms: [cpu, python]
year_introduced: 1980
inputs: [photos]
outputs: [normals, depth]
style: "photoreal"
dynamic: "static"
cost: "offline"
authority: "1980"
url: "https://texelatlas.vercel.app/t/photometric-stereo/"
sources_verified_at: "2026-11-29"
---
# Photometric Stereo (1980)

> Estimates per-pixel surface normals from several photos of a fixed object and camera under different known lighting directions, assuming a simple reflectance model.

## Reach for it when

- recover fine surface relief from photos with changing light
- coins and engravings lose detail in photogrammetry
- get per-pixel normals with fixed camera and varied lighting
- multi-view geometry is too smooth for small detail
- capture skin or fabric micro-geometry

## How it works

Place the camera and object still and capture images while varying the light direction. For a Lambertian surface each pixel's intensity is the dot product of the albedo-scaled normal with the light vector. With three or more known lights this becomes a linear system per pixel, solved by least squares for the scaled normal; its length is albedo and its direction the normal. Extra lights over-determine the system and let you reject shadows and specular highlights as outliers. The normal map is then integrated into a height field, which is a separate problem sensitive to noise and discontinuities. Modern variants relax the assumptions: calibrated non-Lambertian BRDFs, near lights, or learned networks for unknown lighting.

## When to use it

Choose it for fine surface detail (coins, reliefs, skin, fabric) where geometry from multi-view matching is too smooth. Prefer [Universal Photometric Stereo (SDM-UniPS)](https://texelatlas.vercel.app/t/universal-photometric-stereo.md) when lights are uncalibrated or the material is glossy. Prefer [Multi-View Stereo (PatchMatch, COLMAP)](https://texelatlas.vercel.app/t/multi-view-stereo-patchmatch.md) for large-scale shape, and combine the two: MVS for the base shape, photometric normals for detail.

## Cost

offline — Per-pixel linear solve is cheap; the cost is capture and normal integration.
Measured GPU Weight: 5.22× baseline (light) — 0.1617 ms median / 0.1708 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 4.45× baseline (light) — 0.0708 ms median (2.28× faster on L4).
Ampere A100 scaling: 3.53× baseline (light) — 0.1016 ms median (1.59× faster on A100).

## Failure modes

- Specular highlights and cast shadows break the Lambertian assumption and bias normals
- Inaccurate light directions cause a low-frequency bending of the integrated surface
- Inter-reflections in concavities flatten recovered depth
- Integrating normals to depth accumulates drift and smears depth discontinuities

## Dataflow

- Inputs: photos
- Outputs: normals, depth
- Platforms: cpu, python

## Presets

### Photometric Stereo — rotating directional capture I_k (left) vs least-squares recovered normals (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_LIGHT_ELEV": 0.62,
  "P_RELIEF_AMP": 1,
  "P_NOISE_AMT": 0.03,
  "P_SPLIT": 0.48
}
```

```glsl
const float P_LIGHT_ELEV = 0.62; // P Light Elevation [0.25, 0.92, 0.02]
const float P_RELIEF_AMP = 1.0; // P Relief Depth [0.3, 1.8, 0.05]
const float P_NOISE_AMT = 0.03; // P Sensor Noise [0.0, 0.15, 0.005]
const float P_SPLIT = 0.48; // P Capture / Normals [0.0, 1.0, 0.02]

float hash21(vec2 p) {
  p = fract(p * vec2(127.1, 311.7));
  p += dot(p, p + 34.5);
  return fract(p.x * p.y);
}

// Sculpted classical coin / relief medallion heightfield h(u, v) + spatially varying albedo rho(u, v)
void reliefSurface(vec2 p, float amp, out float h, out vec3 albedo, out float mask) {
  float r = length(p);
  mask = smoothstep(0.455, 0.442, r);

  // Stepped coin rim + radial fluting + sculpted inner rosette/dome
  float rim = exp(-pow((r - 0.41) / 0.025, 2.0)) * 0.075;
  float dome = sqrt(max(0.14 - r * r, 0.0)) * 0.42 * smoothstep(0.38, 0.30, r);
  float a = atan(p.y, p.x);
  float petals = sin(a * 8.0) * exp(-pow((r - 0.22) / 0.085, 2.0)) * 0.038;
  float innerRing = exp(-pow((r - 0.11) / 0.022, 2.0)) * 0.045;
  float microGroove = sin(r * 75.0) * 0.0045 * smoothstep(0.40, 0.12, r);
  h = (rim + dome + petals + innerRing + microGroove) * amp;

  // Spatially varying patinated bronze / plaster albedo (photometric stereo separates albedo from normal!)
  float patina = 0.5 + 0.5 * sin(p.x * 9.0 + sin(p.y * 7.0));
  albedo = mix(vec3(0.66, 0.54, 0.42), vec3(0.84, 0.78, 0.68), patina * 0.65 + 0.25 * smoothstep(0.36, 0.10, r));
}

vec3 trueNormal(vec2 p, float amp) {
  float e = 0.0025;
  float h0, hX, hY, m;
  vec3 a;
  reliefSurface(p, amp, h0, a, m);
  reliefSurface(p + vec2(e, 0.0), amp, hX, a, m);
  reliefSurface(p + vec2(0.0, e), amp, hY, a, m);
  return normalize(vec3(-(hX - h0) / e, -(hY - h0) / e, 1.0));
}

vec3 aces(vec3 x) {
  x = max(x, 0.0);
  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  float screenX = fragCoord.x / max(iResolution.x, 1.0);
  float split = clamp(P_SPLIT, 0.0, 1.0);
  bool isRecovered = screenX >= split;
  float elev = clamp(P_LIGHT_ELEV, 0.22, 0.94);
  float amp = clamp(P_RELIEF_AMP, 0.25, 2.0);
  float noiseAmt = clamp(P_NOISE_AMT, 0.0, 0.18);

  vec3 col = mix(vec3(0.025, 0.034, 0.052), vec3(0.062, 0.080, 0.120), smoothstep(-0.5, 0.5, uv.y));
  vec2 g = abs(fract(uv * 10.0 - 0.5) - 0.5);
  col += vec3(0.015, 0.022, 0.036) * smoothstep(0.03, 0.006, min(g.x, g.y));

  float h, mask;
  vec3 albedo;
  reliefSurface(uv, amp, h, albedo, mask);

  // 3 known calibrated light directions L = [l0, l1, l2]^T separated by 120 deg in azimuth
  float rHoriz = sqrt(max(1.0 - elev * elev, 0.01));
  float baseAz = iTime * 0.75;
  vec3 l0 = vec3(cos(baseAz) * rHoriz, sin(baseAz) * rHoriz, elev);
  vec3 l1 = vec3(cos(baseAz + 2.0943951) * rHoriz, sin(baseAz + 2.0943951) * rHoriz, elev);
  vec3 l2 = vec3(cos(baseAz + 4.1887902) * rHoriz, sin(baseAz + 4.1887902) * rHoriz, elev);

  if (mask > 0.005) {
    vec3 nTrue = trueNormal(uv, amp);
    float rho = dot(albedo, vec3(0.299, 0.587, 0.114));

    // Simulate 3 captured Lambertian photographs I_k = rho * max(n . l_k, 0) + sensor noise
    float n0 = (hash21(fragCoord + 1.3) - 0.5) * noiseAmt;
    float n1 = (hash21(fragCoord + 17.7) - 0.5) * noiseAmt;
    float n2 = (hash21(fragCoord + 43.1) - 0.5) * noiseAmt;
    vec3 measI = vec3(
      max(rho * dot(nTrue, l0) + n0, 0.0),
      max(rho * dot(nTrue, l1) + n1, 0.0),
      max(rho * dot(nTrue, l2) + n2, 0.0)
    );

    if (!isRecovered) {
      // Left: Live rotating capture photograph illuminated by active light direction l0
      float liveLit = max(dot(nTrue, l0), 0.0);
      vec3 captureImg = albedo * (0.04 + 1.25 * liveLit) + vec3(n0 * 0.6);
      col = mix(col, captureImg, mask);
    } else {
      // Right: Direct linear Woodham photometric stereo solve: g = inverse(L) * I, n = normalize(g)!
      // Matrix rows are l0, l1, l2 -> in GLSL mat3 columns are transposed, so transpose(mat3(l0, l1, l2))
      mat3 Lmat = transpose(mat3(l0, l1, l2));
      vec3 gVec = inverse(Lmat) * measI;
      vec3 nEst = normalize(gVec + vec3(0.0, 0.0, 1e-4));
      vec3 normMap = nEst * 0.5 + 0.5;
      col = mix(col, normMap, mask);
    }
  }

  // Draw the 3 calibrated light-source beacons orbiting around the medallion perimeter
  for (int k = 0; k < 3; k++) {
    vec3 lk = (k == 0) ? l0 : ((k == 1) ? l1 : l2);
    vec2 beaconPos = lk.xy * (0.48 / max(rHoriz, 0.1)) * 0.94;
    float dB = length(uv - beaconPos);
    vec3 bCol = (k == 0) ? vec3(1.0, 0.88, 0.36) : vec3(0.32, 0.72, 0.98);
    float bRad = (k == 0) ? 0.026 : 0.018;
    col += bCol * smoothstep(bRad * 2.2, bRad * 0.4, dB) * (k == 0 ? 1.1 : 0.55);
  }

  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));
  col = mix(col, vec3(0.95, 0.97, 1.0), sep);

  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}
```

Attribution: MIT — written for this index.

## Lineage

- extended by [Universal Photometric Stereo (SDM-UniPS)](https://texelatlas.vercel.app/t/universal-photometric-stereo.md)

## Combines with

- [Bilateral Normal Integration](https://texelatlas.vercel.app/t/bilateral-normal-integration.md): Photometric stereo produces a normal map; normal integration turns it into a height field.

## Combination ideas

- [Dual-normal varnished surfaces from photometric stereo capture](https://texelatlas.vercel.app/ideas/photometric-micro-normals-clearcoat/)

## Sources

1. [primary] (1980) Photometric Method For Determining Surface Orientation From Multiple Images. Optical Engineering. https://doi.org/10.1117/12.7972479 (verified via crossref on 2026-11-29)

## Cite this entry

Texel. "Photometric Stereo." https://texelatlas.vercel.app/t/photometric-stereo/ (accessed 2026-12-01).
