Texel A field guide to 3D techniques

Universal Photometric Stereo (SDM-UniPS) × Bilateral Normal Integration

Drawings to relief via generated relighting. Turn one drawing into a sharp-edged relief mesh. An image model repaints the same drawing under several lights, photometric stereo that needs no light calibration recovers normals, and discontinuity-aware integration keeps silhouettes as cliffs.

Open in StudioReproduced86.5× · 2.68 ms

Universal Photometric Stereo (SDM-UniPS)Capture · Offlinein: photosout: normalsnormalsBilateral Normal IntegrationCapture · Offlinein: normalsout: depth, mesh

Verified proof

reproduced · 2026-12-01texel-lablicense MIT
Specimen render of Relit drawings to relief (left: smooth Poisson normal integration, right: photometric stereo + bilateral cliff relief)
Cross-proof specimen. Relit drawings to relief (left: smooth Poisson normal integration, right: photometric stereo + bilateral cliff relief). Verified WebGL2 proof · 2026-12-01

Split-screen WebGL2 proof comparing naive smooth Poisson normal integration of a relit botanical medallion drawing (left, where outlines smear into mushy pillowed slopes with lost figure-ground depth) against uncalibrated photometric-stereo normal recovery with bilateral discontinuity-aware integration that carves crisp cliff silhouettes and casts raking relief shadows (right).

Chromium Headless ANGLE/SwiftShader WebGL2 · 512x512 · recovers calibrated-free photometric stereo normals and preserves sharp figure-ground silhouette cliffs via bilateral discontinuity integration

Show GLSL proof (150 lines)
const float P_RELIEF_DEPTH = 0.85; // P Carved Cliff Depth [0.2, 1.6, 0.05]
const float P_BILAT_SHARP = 1.00; // P Discontinuity Sharpness [0.1, 1.8, 0.05]
const float P_LIGHT_SPEED = 0.70; // P Raking Light Orbit [0.0, 1.8, 0.05]
const float P_INK_CONTRAST = 0.45; // P Projected Drawing Ink [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
  );
}

// Signed distance to layered classical lotus rosette medallion + outer bead frame
void evalMedallion(vec2 p, out float dOuter, out float dPetals, out float dCore, out float inkLine) {
  float r = length(p);
  float a = atan(p.y, p.x);

  // Outer carved circular molding ring
  dOuter = abs(r - 0.76) - 0.075;

  // 8 primary pointed lotus petals + 8 recessed secondary sepals
  float wave8 = cos(a * 8.0);
  float wave8b = cos(a * 8.0 + 3.14159265);
  float rPetal = 0.56 + 0.13 * pow(max(wave8, 0.0), 1.4) - 0.08 * pow(max(-wave8, 0.0), 1.2);
  float rSepal = 0.49 + 0.10 * pow(max(wave8b, 0.0), 1.5);
  dPetals = min(r - rPetal, (r - rSepal) + 0.03);

  // Raised central sculpted dome boss
  dCore = r - 0.21;

  // Drawing ink strokes along botanical veins and silhouettes
  float vein = smoothstep(0.024, 0.005, abs(sin(a * 8.0)) * r) * smoothstep(0.66, 0.22, r);
  float outline = smoothstep(0.018, 0.004, abs(dPetals)) + smoothstep(0.018, 0.004, abs(dOuter)) + smoothstep(0.016, 0.004, abs(dCore));
  inkLine = clamp(outline + vein * 0.65, 0.0, 1.0);
}

// Discontinuity-aware BiNI heightfield vs smeared smooth Poisson heightfield
float reliefHeight(vec2 p, bool bilateral) {
  float dOuter, dPetals, dCore, ink;
  evalMedallion(p, dOuter, dPetals, dCore, ink);
  float r = length(p);
  float a = atan(p.y, p.x);

  float paperGrain = (vnoise(p * 36.0) - 0.5) * 0.014;
  if (!bilateral) {
    // Left: smooth continuous integration smears step edges into soft pillowed mounds
    float hRing = exp(-dOuter * dOuter * 38.0) * 0.22;
    float hPet = smoothstep(0.18, -0.18, dPetals) * (0.28 + 0.08 * cos(a * 8.0));
    float hCore = smoothstep(0.14, -0.14, dCore) * 0.20;
    return (hRing + hPet + hCore) * P_RELIEF_DEPTH * 0.72 + paperGrain;
  }
  // Right: bilateral discontinuity weights preserve crisp vertical cliff steps at outlines
  float edgeW = mix(0.045, 0.008, clamp(P_BILAT_SHARP * 0.65, 0.0, 1.0));
  float maskRing = smoothstep(edgeW, -edgeW, dOuter);
  float maskPet = smoothstep(edgeW, -edgeW, dPetals);
  float maskCore = smoothstep(edgeW, -edgeW, dCore);

  // Photometric-stereo internal dome curvature inside each separated island
  float domeRing = sqrt(max(1.0 - pow(clamp((r - 0.76) / 0.075, -1.0, 1.0), 2.0), 0.02));
  float petalRidge = 0.55 + 0.45 * cos(a * 8.0) * smoothstep(0.18, 0.48, r);
  float petalDome = sqrt(max(1.0 - pow(clamp(r / 0.68, 0.0, 1.0), 2.0), 0.05));
  float coreDome = sqrt(max(1.0 - pow(clamp(r / 0.21, 0.0, 1.0), 2.0), 0.02));

  float hRing = maskRing * (0.20 + 0.14 * domeRing);
  float hPet = maskPet * (0.26 + 0.16 * petalDome + 0.09 * petalRidge);
  float hCore = maskCore * (0.44 + 0.18 * coreDome);
  return max(max(hRing, hPet), hCore) * P_RELIEF_DEPTH + paperGrain;
}

vec3 reliefNormal(vec2 p, bool bilateral) {
  float e = bilateral ? 0.0045 : 0.018;
  float hx = reliefHeight(p + vec2(e, 0.0), bilateral) - reliefHeight(p - vec2(e, 0.0), bilateral);
  float hy = reliefHeight(p + vec2(0.0, e), bilateral) - reliefHeight(p - vec2(0.0, e), bilateral);
  return normalize(vec3(-hx, -hy, 2.0 * e));
}

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 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  bool useBiNI = uv.x > 0.0;
  vec2 p = vec2(useBiNI ? (uv.x - 0.25) : (uv.x + 0.25), uv.y) * 2.15;

  // Orbiting raking studio key light revealing relief cliffs vs mushy slopes
  float la = iTime * 0.72 * P_LIGHT_SPEED + 0.75;
  vec3 L = normalize(vec3(cos(la) * 0.84, sin(la) * 0.52 + 0.24, 0.42));
  vec3 V = vec3(0.0, 0.0, 1.0);

  float h = reliefHeight(p, useBiNI);
  vec3 N = reliefNormal(p, useBiNI);

  // Horizon-marching raking self-shadow across carved relief cliffs
  float shadow = 1.0;
  vec2 lStep = normalize(L.xy + vec2(1e-4)) * 0.016;
  float slopeZ = L.z / max(length(L.xy), 0.15);
  for (int i = 1; i <= 14; i++) {
    float fi = float(i);
    float hs = reliefHeight(p + lStep * fi, useBiNI);
    float rayH = h + slopeZ * (0.016 * fi) * 0.72;
    if (hs > rayH) {
      float occ = clamp((hs - rayH) * (useBiNI ? 16.0 : 5.0), 0.0, 1.0);
      shadow = min(shadow, 1.0 - occ * 0.85);
    }
  }

  float dOuter, dPetals, dCore, ink;
  evalMedallion(p, dOuter, dPetals, dCore, ink);
  // Warm travertine / sculpted alabaster plaster with subtle projected ink drawing lines
  float grain = vnoise(p * 18.0);
  vec3 tabletBase = mix(vec3(0.76, 0.71, 0.63), vec3(0.86, 0.82, 0.75), grain);
  // Recessed background slightly darker parchment stone
  float isRaised = smoothstep(0.08, 0.22, h / max(P_RELIEF_DEPTH, 0.1));
  vec3 alb = mix(tabletBase * 0.72, tabletBase, isRaised);
  // Subtle charcoal ink projection from original drawing
  alb = mix(alb, vec3(0.18, 0.16, 0.15), ink * P_INK_CONTRAST * 0.75);

  float ndl = max(dot(N, L), 0.0);
  vec3 H = normalize(L + V);
  float spec = pow(max(dot(N, H), 0.0), useBiNI ? 44.0 : 18.0);
  // Ambient occlusion tucked right along cliff crevices
  float hAvg = 0.25 * (
    reliefHeight(p + vec2(0.025, 0.0), useBiNI) +
    reliefHeight(p - vec2(0.025, 0.0), useBiNI) +
    reliefHeight(p + vec2(0.0, 0.025), useBiNI) +
    reliefHeight(p - vec2(0.0, 0.025), useBiNI)
  );
  float ao = clamp(1.0 - max(hAvg - h, 0.0) * 5.2, 0.32, 1.0);

  vec3 warmKey = vec3(1.42, 1.24, 1.02) * ndl * shadow;
  vec3 coolFill = vec3(0.24, 0.30, 0.40) * (0.45 + 0.55 * max(dot(N, normalize(vec3(-L.x, -L.y, 0.6))), 0.0)) * ao;
  vec3 col = alb * (warmKey + coolFill) + vec3(1.15, 1.05, 0.92) * spec * shadow * (useBiNI ? 0.36 : 0.14);

  // Subtle framing vignette
  col *= smoothstep(1.48, 0.72, length(p));
  col = acesTone(col * 1.12);
  if (abs(uv.x) < 0.003) 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

The input is a set of images of one drawing, each relit from a different direction by an image-generation or relighting model while the composition stays fixed; they stand in for the photos io-type. Universal Photometric Stereo (SDM-UniPS) consumes that stack and outputs normals without being told where the lights are, which matters because generated lighting is never calibrated. Bilateral Normal Integration takes the normals and integrates them into depth and a mesh, using bilateral weights to decide where neighbouring pixels sit across a step, so a figure's outline separates from the background instead of being smeared into a slope.

How to build it

Python pipeline. Generate six to twelve relit variants of the drawing with a structure-preserving method (a relighting model, or an image model with line-art or depth conditioning and a fixed seed), varying only the light direction. Register the variants to the original to remove drift. Run SDM-UniPS on the stack to get a normal map, then mask the background. Integrate with the BiNI reference code using the orthographic model, triangulate the depth grid, decimate with Quadric Error Metric Simplification, and project the original drawing back on as the texture. Expect a bas-relief rather than a full 3D shape and scale depth by hand. Smooth regions where normals disagree across variants before integrating.

Field marks

  1. The image model changes shapes between lightings, so per-pixel observations disagree and normals turn to noise.
  2. Drawn or generated shading is not physically consistent, which photometric stereo assumes it is.
  3. Too little lighting variety leaves the bas-relief ambiguity unresolved.
  4. Wrong discontinuity decisions put cliffs in the wrong places.

Prior art

No prior art found on 2026-11-29.

Searches run (4)
  • arXiv: all:"photometric stereo" AND all:"generated images" → 0 results
  • GitHub repos: "photometric stereo" "generated images" → 0 results
  • arXiv: all:"normal integration" AND all:"sketch" AND all:"relief" → 0 results
  • GitHub repos: "normal integration" sketch relief → 0 results