Photometric Stereo × Clearcoat layer
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.
Open in StudioReproduced30.3× · 0.941 ms
Verified proof

Split-screen WebGL2 proof comparing raw dry photometric-stereo micro-normals shaded with a single matte lobe (left) against a dual-normal physically based clearcoat BRDF layering a smooth dielectric lacquer topcoat over crisp photometric wood-grain and carved chisel micro-normals (right).
Chromium Headless ANGLE/SwiftShader WebGL2 · 512x512 · decouples crisp photometric-stereo base micro-normals from a smooth dielectric clearcoat topcoat with Beer-Lambert resin depth and edge wear
Show GLSL proof (152 lines)
const float P_COAT_THICK = 0.92; // P Lacquer Thickness [0.0, 1.4, 0.05]
const float P_COAT_ROUGH = 0.09; // P Clearcoat Rough [0.03, 0.35, 0.01]
const float P_MICRO_GAIN = 1.15; // P Photometric Relief [0.2, 2.0, 0.05]
const float P_WEAR_SCUFF = 0.32; // P Edge Scuff Wear [0.0, 1.0, 0.05]
float hash21(vec2 p) {
p = fract(p * vec2(127.1, 311.7));
p += dot(p, p + 34.5);
return fract(p.x * p.y);
}
float vnoise(vec2 p) {
vec2 i = floor(p);
vec2 f = fract(p);
vec2 u = f * f * (3.0 - 2.0 * f);
return mix(
mix(hash21(i), hash21(i + vec2(1.0, 0.0)), u.x),
mix(hash21(i + vec2(0.0, 1.0)), hash21(i + vec2(1.0, 1.0)), u.x),
u.y
);
}
// Ground-truth crafted medallion relief height (wood grain + radial carved flutes + hammered dimples)
float craftHeight(vec2 uv) {
float r = length(uv);
float a = atan(uv.y, uv.x);
float grain = sin(uv.x * 26.0 + vnoise(uv * 5.0) * 4.5) * 0.35 + vnoise(vec2(uv.x * 48.0, uv.y * 10.0)) * 0.25;
float rosette = sin(a * 16.0) * exp(-pow((r - 0.56) * 6.5, 2.0)) * 0.65;
float ringGroove = -exp(-pow((r - 0.34) * 18.0, 2.0)) * 0.75;
float chisel = (vnoise(uv * 32.0) - 0.5) * 0.32;
return (grain * 0.45 + rosette + ringGroove + chisel) * P_MICRO_GAIN;
}
// Photometric stereo normal recovery from 4 orthogonal directional light observations
vec3 photometricNormal(vec2 uv, float stepEps) {
float hL = craftHeight(uv - vec2(stepEps, 0.0));
float hR = craftHeight(uv + vec2(stepEps, 0.0));
float hD = craftHeight(uv - vec2(0.0, stepEps));
float hU = craftHeight(uv + vec2(0.0, stepEps));
// Solve 4-light photometric intensity ratios (I_R - I_L, I_U - I_D) -> tangent normal
vec2 grad = vec2(hR - hL, hU - hD) / max(2.0 * stepEps, 1e-4);
return normalize(vec3(-grad.x * 0.045, -grad.y * 0.045, 1.0));
}
// GGX NDF for physically based base & clearcoat specular lobes
float ggxD(float ndh, float rough) {
float a = max(rough * rough, 0.002);
float a2 = a * a;
float d = ndh * ndh * (a2 - 1.0) + 1.0;
return a2 / max(3.14159 * d * d, 1e-5);
}
vec3 studioEnv(vec3 R) {
float h = clamp(R.y * 0.6 + 0.45, 0.0, 1.0);
vec3 base = mix(vec3(0.07, 0.08, 0.11), vec3(0.24, 0.28, 0.36), h);
float softbox1 = smoothstep(0.74, 0.94, dot(R, normalize(vec3(0.55, 0.68, 0.48))));
float softbox2 = smoothstep(0.80, 0.96, dot(R, normalize(vec3(-0.68, 0.35, 0.64))));
return base + vec3(2.8, 2.55, 2.20) * softbox1 + vec3(0.85, 1.25, 1.85) * softbox2;
}
vec3 acesTone(vec3 x) {
return clamp((x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14), 0.0, 1.0);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 res = max(iResolution.xy, vec2(1.0));
vec2 uvN = fragCoord / res;
float splitX = iMouse.z > 0.0 ? clamp(iMouse.x / res.x, 0.05, 0.95) : 0.5;
bool useClearcoat = uvN.x > splitX;
vec2 p = (fragCoord - 0.5 * res) / res.y;
float t = iTime;
vec3 ro = vec3(0.0, 0.12, 2.35);
vec3 rd = normalize(vec3(p.x * 1.05, p.y - 0.04, -1.65));
vec3 bg = mix(vec3(0.06, 0.07, 0.09), vec3(0.14, 0.16, 0.21), clamp(p.y + 0.55, 0.0, 1.0));
vec3 col = bg;
// Ray-intersect curved studio medallion dome (flattened ellipsoid)
vec3 sc = vec3(0.92, 0.92, 0.46);
vec3 qro = ro / sc;
vec3 qrd = rd / sc;
float a = dot(qrd, qrd);
float b = dot(qro, qrd);
float c = dot(qro, qro) - 1.0;
float disc = b * b - a * c;
if (disc > 0.0) {
float tHit = (-b - sqrt(disc)) / max(a, 1e-5);
vec3 wp = ro + rd * tHit;
vec3 macroN = normalize(wp / (sc * sc));
vec3 upRef = vec3(0.0, 1.0, 0.0);
vec3 T = normalize(cross(upRef, macroN));
vec3 B = cross(macroN, T);
// Rotate surface UVs gently for live specular inspection
float spin = sin(t * 0.45) * 0.28;
mat2 rot = mat2(cos(spin), -sin(spin), sin(spin), cos(spin));
vec2 surfUV = rot * wp.xy;
// Fine photometric-stereo recovered base micro-normal
vec3 tsBase = photometricNormal(surfUV, 0.008);
vec3 Nbase = normalize(T * tsBase.x + B * tsBase.y + macroN * tsBase.z);
// Bilateral-smoothed clearcoat normal representing pooled lacquer filling fine scratches
vec3 tsCoat = photometricNormal(surfUV, 0.065);
vec3 Ncoat = normalize(mix(macroN, normalize(T * tsCoat.x + B * tsCoat.y + macroN * tsCoat.z), 0.22));
// Craft walnut wood & inlaid brass ring albedo
float r = length(surfUV);
float grainW = 0.5 + 0.5 * sin(surfUV.x * 26.0 + vnoise(surfUV * 5.0) * 4.5);
vec3 walnut = mix(vec3(0.24, 0.11, 0.05), vec3(0.46, 0.23, 0.10), grainW);
float brassMask = smoothstep(0.032, 0.012, abs(r - 0.34));
vec3 baseAlb = mix(walnut, vec3(0.78, 0.60, 0.26), brassMask);
// Animated key light + rim light
vec3 L1 = normalize(vec3(cos(t * 0.65) * 0.72, 0.68, 0.58 + sin(t * 0.65) * 0.25));
vec3 L2 = normalize(vec3(-0.72, 0.34, 0.60));
vec3 V = -rd;
// Base layer evaluation using crisp photometric micro-normals
float ndl1B = max(dot(Nbase, L1), 0.0);
float ndl2B = max(dot(Nbase, L2), 0.0);
float ndh1B = max(dot(Nbase, normalize(L1 + V)), 0.0);
float baseRough = mix(0.42, 0.22, brassMask);
vec3 baseSpec = mix(vec3(0.04), vec3(0.88, 0.68, 0.32), brassMask) * ggxD(ndh1B, baseRough) * 0.22 * ndl1B;
vec3 baseLit = baseAlb * (vec3(0.14, 0.15, 0.18) + vec3(1.35, 1.22, 1.05) * ndl1B + vec3(0.32, 0.44, 0.62) * ndl2B) + baseSpec;
if (!useClearcoat) {
// Left baseline: raw dry photometric micro-normals with zero lacquer topcoat
col = baseLit;
} else {
// Right: dual-normal dielectric clearcoat with Beer-Lambert amber resin tint & edge scuff mask
float wearNoise = vnoise(surfUV * 12.0 + 3.1);
float coatMask = clamp(P_COAT_THICK * (1.0 - P_WEAR_SCUFF * smoothstep(0.42, 0.78, r * 0.85 + wearNoise * 0.45)), 0.0, 1.0);
float ndvC = max(dot(Ncoat, V), 0.04);
float fresC = (0.04 + 0.96 * pow(1.0 - ndvC, 5.0)) * coatMask;
// Beer-Lambert optical path deepening warm wood under glossy lacquer
vec3 coatTint = exp(-vec3(0.18, 0.42, 0.75) * (0.45 * coatMask / max(ndvC, 0.25)));
float ndh1C = max(dot(Ncoat, normalize(L1 + V)), 0.0);
float ndl1C = max(dot(Ncoat, L1), 0.0);
float coatSpec = ggxD(ndh1C, P_COAT_ROUGH) * 0.18 * ndl1C * coatMask;
vec3 coatRefl = studioEnv(reflect(-V, Ncoat));
// Energy-conserving dual-layer composition: attenuate base by (1 - F_c) * resin absorption
col = baseLit * coatTint * (1.0 - fresC) + coatRefl * fresC * 1.15 + vec3(1.35, 1.30, 1.22) * coatSpec;
}
}
col = acesTone(col * 1.08);
if (abs(fragCoord.x - splitX * res.x) < 1.0) col = vec3(0.95, 0.93, 0.89);
fragColor = vec4(pow(clamp(col, 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Why they connect
Photometric Stereo recovers a dense per-pixel normal map and integrated depth relief from multi-light observations under known illumination directions. Those recovered normals flow directly into Clearcoat layer as the underlying base-layer normal map, while a low-pass filtered version of the same normal field (or a separately thresholded specular lobe residual) drives the clearcoat normal. Clearcoat layer then evaluates dual-lobe GGX shading where light refracts and attenuates through the dielectric coat before interacting with the crisp photometric micro-relief beneath.
How to build it
Solve linear or robust photometric stereo across 4-8 directional light observations (or synthesize live multi-light inputs on a procedural relief specimen in WebGL2) to obtain per-pixel base normals N_base and diffuse albedo. Compute a bilateral-smoothed coat normal N_coat representing pooled resin or lacquer that fills fine scratches while following macro-curvature. Feed N_base, N_coat, base roughness, coat roughness, and coat thickness into a physically based clearcoat BRDF shader: evaluate dielectric Fresnel F_c at N_coat, attenuate the base diffuse and specular lobes by (1 - F_c) and Beer-Lambert coat tint, and expose interactive sliders for varnish thickness and wear masks.
Field marks
- Specular highlights already present in the input photographs bias linear Lambertian photometric stereo normal estimates unless median/RANSAC or cross-polarized light rejection is applied.
- High-frequency photometric noise aliases into shimmering base glints under a smooth glossy clearcoat without Toksvig or LEAN normal-to-roughness filtering.
- Energy loss occurs if the dielectric coat reflection is added naively without attenuating the underlying base BRDF by transmittance.
- Strong self-shadowing in deep carved grooves violates simple photometric stereo assumptions and tilts normals away from light directions.
Prior art
No prior art found on 2026-12-01.
Searches run (2)
- arXiv: all:"photometric stereo" AND all:"clearcoat"
- GitHub repos: "photometric stereo" clearcoat