Least Squares Conformal Maps
Computes a UV parameterization of a mesh chart by minimising the deviation from a conformal (angle-preserving) map with a linear least-squares solve, pinning two vertices to remove the rigid-body freedom.
In the family Geometry, meshing & signed distance fields, UV parameterization
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 | Built in | ArrayMesh.lightmap_unwrap() / Mesh Import > Light Baking = Static Lightmaps (bundled xatlas uses ChartType::LSCM parameterization) docs |
| Unity | None found | Unwrapping.GenerateSecondaryUVSet generates internal lightmap UVs without exposing an LSCM UV parameterization tool. |
| Unreal 5.7 | Built in | Modeling Mode > UVs > Unwrap and Geometry Script (GeometryScriptUVFlattenMethod.CONFORMAL / SPECTRAL_CONFORMAL, or auto_generate_x_atlas) docs |
| Blender 5.2 | Built in | UV Editing > UV > Unwrap > Conformal (Angle Based is the alternative) docs |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
The Cauchy-Riemann equations say a map is conformal when its gradient is a rotation plus scale. On a triangle mesh, each triangle is expressed in a local orthonormal basis and the conformality error is a quadratic function of the UV coordinates. Summing the squared errors over triangles gives a sparse least-squares system. A pair of vertices is pinned to fix translation, rotation and scale (or boundary conditions are provided); solving the symmetric positive-definite system gives UVs that preserve angles as well as possible. The method works with free boundaries, so a disc-topology chart takes its natural shape. Charts are usually produced by cutting seams along a spanning tree or by a segmentation step beforehand, and area distortion is often fixed by a following packing/scaling stage.
When to choose it
Reach for it when
- need quick uvs for a single patch after marking seams
- texture stretches when unwrapping a mesh section
- angle-preserving unwrap for painting
- unfold a disc-like chart without much shear
- uv map for baking a hand-seamed piece
Choose it for quick, stable unwrapping of a single disc-like chart: hand-seam workflows, texture painting and baking. Prefer xatlas when you need automatic chart segmentation and packing of the whole mesh, Geometry Images when you want a single square chart for the entire surface, and an area-preserving method when texel density must be uniform.
Field marks
- Angle preservation means area can blow up: large stretch near sharp cone-like regions
- Flipped triangles can still appear since the objective does not forbid them
- Depends on which two vertices are pinned and on the seam layout
- Charts with high Gaussian curvature need many seams, creating visible texture breaks
Presets
Least Squares Conformal Maps — sheared planar UV (left) vs angle-preserving conformal UV & Tissot circles (right)
{
"P_UV_FREQ": 8,
"P_TISSOT_CIRCLES": 0.85,
"P_SPLIT": 0.45,
"P_ROT_SPEED": 1
}Show GLSL (131 lines)
const float P_UV_FREQ = 8.0; // P Checker Density [4.0, 16.0, 1.0]
const float P_TISSOT_CIRCLES = 0.85; // P Tissot Indicatrix [0.0, 1.5, 0.05]
const float P_SPLIT = 0.45; // P Planar / LSCM Split [0.0, 1.0, 0.02]
const float P_ROT_SPEED = 1.0; // P Spin Speed [0.0, 2.5, 0.05]
mat2 rot2(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }
// Sculpted undulating hourglass/vase manifold with strong positive & negative Gaussian curvature
float mapSurface(vec3 p, float spin) {
vec3 q = p;
q.xz = rot2(spin * 0.35) * q.xz;
q.yz = rot2(0.28) * q.yz;
float ang = atan(q.z, q.x);
float profileR = 0.56 + 0.22 * cos(q.y * 3.8) + 0.08 * sin(ang * 3.0) * cos(q.y * 2.2);
float dCyl = length(q.xz) - profileR;
float dCap = abs(q.y) - 0.82;
vec2 w = vec2(dCyl, dCap);
return (min(max(w.x, w.y), 0.0) + length(max(w, 0.0)) - 0.04) * 0.72;
}
vec3 calcNormal(vec3 p, float spin) {
vec2 e = vec2(0.0025, 0.0);
return normalize(vec3(
mapSurface(p + e.xyy, spin) - mapSurface(p - e.xyy, spin),
mapSurface(p + e.yxy, spin) - mapSurface(p - e.yxy, spin),
mapSurface(p + e.yyx, spin) - mapSurface(p - e.yyx, spin)
));
}
// Evaluate UV checkerboard + Tissot indicatrix circles (circles stay strictly circular ONLY under conformal maps!)
vec3 evalUvPattern(vec2 uvTex, float freq, float tissotAmt, float scaleFactor) {
vec2 g = uvTex * freq;
vec2 cell = floor(g);
vec2 f = fract(g) - 0.5;
float chk = mod(cell.x + cell.y, 2.0);
// Subtle conformal area-scale color ramp (teal = compressed, ivory = neutral, amber = expanded)
vec3 scaleTint = mix(vec3(0.18, 0.62, 0.84), vec3(0.95, 0.64, 0.24), clamp(scaleFactor, 0.0, 1.0));
vec3 base = mix(vec3(0.16, 0.20, 0.26), mix(vec3(0.86, 0.88, 0.90), scaleTint, 0.45), chk);
// Orthogonal UV gridlines (preserve exact 90-degree crossings under LSCM!)
float gridLine = smoothstep(0.055, 0.015, min(abs(f.x), abs(f.y)));
base = mix(base, vec3(0.06, 0.09, 0.14), gridLine * 0.45);
// Tissot indicatrix circles centered in every UV tile: distortion reveals shear immediately!
if (tissotAmt > 0.01) {
float r = length(f);
float ring = smoothstep(0.055, 0.012, abs(r - 0.28));
base = mix(base, vec3(0.98, 0.34, 0.32), ring * 0.82 * min(tissotAmt, 1.2));
}
return base;
}
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);
float freq = clamp(floor(P_UV_FREQ + 0.5), 3.0, 18.0);
float tissot = clamp(P_TISSOT_CIRCLES, 0.0, 1.5);
float spin = iTime * max(P_ROT_SPEED, 0.0);
vec3 ro = vec3(0.0, 0.08, 2.55);
vec3 rd = normalize(vec3(uv, -1.52));
vec3 col = mix(vec3(0.03, 0.042, 0.068), vec3(0.092, 0.118, 0.170), smoothstep(-0.55, 0.55, uv.y));
vec2 bgG = abs(fract(uv * 10.0 - 0.5) - 0.5);
col += vec3(0.018, 0.028, 0.045) * smoothstep(0.03, 0.0, min(bgG.x, bgG.y));
float t = 0.0;
bool hit = false;
for (int i = 0; i < 64; i++) {
float d = mapSurface(ro + rd * t, spin);
if (d < 0.002) { hit = true; break; }
t += d;
if (t > 9.0) break;
}
if (hit) {
vec3 p = ro + rd * t;
vec3 n = calcNormal(p, spin);
// Object-space coordinates on the curved surface of revolution
vec3 objP = p;
objP.xz = rot2(spin * 0.35) * objP.xz;
objP.yz = rot2(0.28) * objP.yz;
// Left: Naive Planar UV projection (causes severe shear & stretched Tissot ellipses on curved flanks!)
vec2 naiveUV = objP.xy * 0.65;
// Right: Exact Isothermal / Conformal LSCM parameterization!
// For a surface of revolution r(y), conformal coordinate satisfies dv = ds / r(y) so metric is isotropic: ds^2 = r^2(du^2 + dv^2)!
float theta = atan(objP.z, objP.x);
float rSurf = max(length(objP.xz), 0.18);
// Integrate meridian arc-length / r(y) using 6-tap midpoint quadrature for true angle-preserving LSCM UV!
float vConf = 0.0;
float dy = objP.y / 6.0;
for (int k = 0; k < 6; k++) {
float ym = (float(k) + 0.5) * dy;
float rm = 0.56 + 0.22 * cos(ym * 3.8) + 0.08 * sin(theta * 3.0) * cos(ym * 2.2);
float drdy = -0.22 * 3.8 * sin(ym * 3.8) - 0.08 * 2.2 * sin(theta * 3.0) * sin(ym * 2.2);
float ds = sqrt(1.0 + drdy * drdy) * dy;
vConf += ds / max(rm, 0.22);
}
vec2 lscmUV = vec2(theta / 3.14159265, vConf / 3.14159265);
float confScale = clamp((rSurf - 0.32) / 0.50, 0.0, 1.0);
bool isLscm = screenX >= split;
vec3 alb = isLscm
? evalUvPattern(lscmUV, freq, tissot, confScale)
: evalUvPattern(naiveUV, freq, tissot, 0.5);
vec3 l1 = normalize(vec3(0.62, 0.86, 0.55));
vec3 l2 = normalize(vec3(-0.75, -0.22, 0.52));
float diff1 = max(dot(n, l1), 0.0);
float diff2 = max(dot(n, l2), 0.0);
vec3 hVec = normalize(l1 - rd);
float spec = pow(max(dot(n, hVec), 0.0), 42.0) * 0.42;
float rim = pow(1.0 - max(dot(n, -rd), 0.0), 3.0) * 0.26;
col = alb * (0.28 + 0.82 * diff1 + 0.24 * diff2) + vec3(spec) + vec3(0.45, 0.72, 1.0) * rim;
}
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: Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| lscm-uv-unwrapping-live | Tesla T4 1920x1080 | 25.7× baseline (heavy) · 0.807 ms / 0.820 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| lscm-uv-unwrapping-live | NVIDIA L4 1920x1080 | 21.6× baseline (heavy) · 0.341 ms / 0.347 ms · 2.4× faster on L4 | opengl-timer-query · Cross-architecture validation |
| lscm-uv-unwrapping-live | NVIDIA A100-SXM4-40GB 1920x1080 | 15.4× baseline (moderate) · 0.443 ms / 0.449 ms · 1.8× faster on A100 | opengl-timer-query · Cross-architecture validation |
Crosses
- xatlas: The atlas generator uses chart-level parameterization of this sort before packing.
Sources
- primaryBruno Lévy, Sylvain Petitjean, Nicolas Ray, Jérome Maillot (2002). Least squares conformal maps for automatic texture atlas generation. Proceedings of the 29th annual conference on Computer graphics and interactive techniques.Verified via crossref · 2026-11-29doi:10.1145/566570.566590
- implementationjpcy (2018). jpcy/xatlas. Mesh parameterization / UV unwrapping libraryGitHub API · license MIT · 2026-11-29