Photometric Stereo
Estimates per-pixel surface normals from several photos of a fixed object and camera under different known lighting directions, assuming a simple reflectance model.
Also known as shape from shading, multi-light
In the family Capture, reconstruction & splatting, shape from shading
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | Not applicable | Offline reconstruction/generative method, not an engine feature. |
| Unity | None found | |
| Unreal 5.7 | None found | External multi-illumination capture reconstruction method; not built into Unreal Engine. |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
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 choose it
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
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) when lights are uncalibrated or the material is glossy. Prefer Multi-View Stereo (PatchMatch, COLMAP) for large-scale shape, and combine the two: MVS for the base shape, photometric normals for detail.
Field marks
- 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
Presets
Photometric Stereo — rotating directional capture I_k (left) vs least-squares recovered normals (right)
{
"P_LIGHT_ELEV": 0.62,
"P_RELIEF_AMP": 1,
"P_NOISE_AMT": 0.03,
"P_SPLIT": 0.48
}Show GLSL (114 lines)
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.
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| photometric-stereo-live | Tesla T4 1920x1080 | 5.22× baseline (light) · 0.162 ms / 0.171 ms | opengl-timer-query · 36 frames · GPU Weight Atlas · Colab T4 sweep |
| photometric-stereo-live | NVIDIA L4 1920x1080 | 4.45× baseline (light) · 0.071 ms / 0.072 ms · 2.3× faster on L4 | opengl-timer-query · Cross-architecture validation |
| photometric-stereo-live | NVIDIA A100-SXM4-40GB 1920x1080 | 3.53× baseline (light) · 0.102 ms / 0.102 ms · 1.6× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
Crosses
- Dual-normal varnished surfaces from photometric stereo capture: Separating high-frequency brush, wood-grain, or hammered-metal micro-normals recovered via photometric stereo from a smoother lacquer topcoat lets real-world craft materials be re-varnished, scuffed, or wet-coated interactively.
- Bilateral Normal Integration: Photometric stereo produces a normal map; normal integration turns it into a height field.
Sources
- primary (1980). Photometric Method For Determining Surface Orientation From Multiple Images. Optical Engineering.Verified via crossref · 2026-11-29doi:10.1117/12.7972479