---
id: "shape-matching-deformation"
title: "Shape matching (meshless deformation)"
aliases: [Meshless deformations]
domain: "simulation"
stage: "simulation"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, cpu, unity]
year_introduced: 2005
inputs: [particles]
outputs: [particles, mesh]
style: "both"
dynamic: "dynamic"
cost: "cheap"
authority: "Müller et al., 2005"
url: "https://texelatlas.vercel.app/t/shape-matching-deformation/"
sources_verified_at: "2026-11-29"
---
# Shape matching (meshless deformation) (Müller et al., 2005)

> Soft-body method that pulls each particle toward the best-fit rigid transform of its rest shape, giving stable, controllable deformable objects without a mesh.

## Reach for it when

- want cheap jelly or plush squishy objects
- soft body without a volumetric mesh
- need stable secondary motion in games
- deformable objects explode with spring-based methods

## How it works

Given particles with rest positions and current positions, compute the optimal rotation (and translation) that maps the rest shape onto the current one: the centre of mass for translation and a polar decomposition of the covariance matrix `A_pq` for rotation. Each particle's goal position is its rest position under this transform, and particles are moved toward their goals by a stiffness factor. Adding a linear or quadratic transformation to the fit lets the object shear, stretch or bend. Multiple overlapping clusters give local deformation instead of a single global one. Time integration is explicit and unconditionally stable because the goal is geometric.

## When to use it

Choose it for cheap jelly, plush and secondary-motion deformation in games. Prefer [Extended Position-Based Dynamics](https://texelatlas.vercel.app/t/xpbd.md) when you need volume constraints and calibrated stiffness, [Position Based Dynamics](https://texelatlas.vercel.app/t/position-based-dynamics.md) for cloth/ropes, and [Vertex Block Descent](https://texelatlas.vercel.app/t/vertex-block-descent.md) when you need accurate elasticity.

## Cost

cheap — Cheap: a covariance and polar decomposition per cluster.
Measured GPU Weight: 49.32× baseline (heavy) — 1.5288 ms median / 1.6285 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 43.44× baseline (heavy) — 0.6907 ms median (2.21× faster on L4).
Ampere A100 scaling: 33.35× baseline (heavy) — 0.9605 ms median (1.59× faster on A100).

## Failure modes

- Does not model true elasticity; large deformations look like a springy blob
- Polar decomposition can flip on inverted configurations
- Global fit makes the object too rigid, clusters give seams
- Stiffness is a blend factor, not a material parameter

## Dataflow

- Inputs: particles
- Outputs: particles, mesh
- Platforms: webgl2, webgpu, desktop-gpu, cpu, unity

## Presets

### Shape Matching Deformation — meshless soft-body polar-decomposition goal lattice & elastic pull (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_STIFFNESS": 0.62,
  "P_SQUASH_AMP": 1,
  "P_GOAL_VIS": 0.85,
  "P_BOUNCE_SPD": 1
}
```

```glsl
const float P_STIFFNESS = 0.62; // P Stiffness Alpha [0.1, 1.0, 0.02]
const float P_SQUASH_AMP = 1.0; // P Impact Squash [0.2, 1.8, 0.05]
const float P_GOAL_VIS = 0.85; // P Goal Pose Overlay [0.0, 1.5, 0.05]
const float P_BOUNCE_SPD = 1.0; // P Bounce Speed [0.0, 2.5, 0.05]

mat2 rot2(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }

float sdSeg(vec2 p, vec2 a, vec2 b) {
  vec2 pa = p - a;
  vec2 ba = b - a;
  float h = clamp(dot(pa, ba) / max(dot(ba, ba), 1e-5), 0.0, 1.0);
  return length(pa - ba * h);
}

// Compute bouncing rigid goal center, polar-decomposition rotation, and deformed lattice point
void evalSoftBody(vec2 rest, float t, float stiff, float amp, out vec2 goalPos, out vec2 defPos) {
  // Periodic bounce cycle on floor y = -0.34
  float cyc = fract(t * 0.42);
  float air = 4.0 * cyc * (1.0 - cyc);
  float impact = exp(-pow((cyc - 0.03) * 8.0, 2.0)) + exp(-pow((cyc - 0.97) * 8.0, 2.0));
  float centerY = -0.14 + air * 0.34;
  float centerX = 0.14 * sin(t * 0.85);
  float rotAng = 0.45 * sin(t * 1.1) + 0.18 * (1.0 - air);

  // Best-fit rigid goal configuration g_i = R * q_i + c_cm
  vec2 c = vec2(centerX, centerY);
  goalPos = c + rot2(rotAng) * rest;

  // Non-rigid squash-and-stretch + shear modes damped by shape-matching stiffness alpha
  float compliance = (1.0 - stiff * 0.78) * amp;
  float sy = 1.0 - 0.36 * impact * compliance + 0.14 * sin(t * 7.5) * compliance * 0.45;
  float sx = 1.0 / max(sy, 0.45); // area-preserving deformation
  float shear = 0.24 * cos(t * 2.6) * compliance * (rest.y + 0.16);

  vec2 localDef = vec2(rest.x * sx + shear, rest.y * sy);
  // Quadratic bend mode during impact
  localDef.y += 0.35 * impact * compliance * (rest.x * rest.x - 0.018);

  vec2 rawDef = c + rot2(rotAng) * localDef;
  // Clamp against floor plane y = -0.34
  rawDef.y = max(rawDef.y, -0.335);

  // Shape matching pull: x_i <- x_i + alpha * (g_i - x_i)
  defPos = mix(rawDef, goalPos, stiff * 0.48);
  defPos.y = max(defPos.y, -0.335);
}

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 px = 1.0 / max(iResolution.y, 1.0);
  float stiff = clamp(P_STIFFNESS, 0.08, 1.0);
  float amp = clamp(P_SQUASH_AMP, 0.15, 2.0);
  float goalVis = clamp(P_GOAL_VIS, 0.0, 1.5);
  float t = iTime * max(P_BOUNCE_SPD, 0.0);

  // Lab backdrop + floor
  vec3 col = mix(vec3(0.025, 0.036, 0.058), vec3(0.056, 0.076, 0.118), smoothstep(-0.5, 0.5, uv.y));
  vec2 grid = abs(fract(uv * 10.0 - 0.5) - 0.5);
  col += vec3(0.015, 0.024, 0.040) * smoothstep(0.035, 0.008, min(grid.x, grid.y));

  // Rigid floor surface at y = -0.34
  if (uv.y < -0.34) {
    float floorGrid = smoothstep(0.04, 0.01, abs(fract(uv.x * 8.0) - 0.5));
    col = mix(vec3(0.07, 0.09, 0.13), vec3(0.14, 0.18, 0.25), floorGrid * 0.6);
  }
  col = mix(col, vec3(0.55, 0.72, 0.90), smoothstep(px * 3.0, px * 0.6, abs(uv.y + 0.34)) * 0.85);

  // Evaluate 5x5 meshless particle grid (25 particles)
  float bodyField = 0.0;
  float dispSum = 0.0;
  float minDef = 1e5;
  float minGoal = 1e5;
  float pullLine = 0.0;
  float goalHull = 0.0;

  for (int iy = 0; iy < 5; iy++) {
    for (int ix = 0; ix < 5; ix++) {
      vec2 rest = (vec2(float(ix), float(iy)) - 2.0) * 0.078;
      vec2 gPos, dPos;
      evalSoftBody(rest, t, stiff, amp, gPos, dPos);

      float dd = length(uv - dPos);
      float dg = length(uv - gPos);
      minDef = min(minDef, dd);
      minGoal = min(minGoal, dg);

      float disp = length(gPos - dPos);
      float w = exp(-dd * dd / 0.0036);
      bodyField += w;
      dispSum += w * disp;

      // Elastic restoration vector alpha * (g_i - x_i)
      float dPull = sdSeg(uv, dPos, gPos);
      pullLine = max(pullLine, smoothstep(px * 2.6, px * 0.6, dPull) * smoothstep(0.004, 0.02, disp));

      // Draw goal rigid wireframe boundary
      if (ix < 4) {
        vec2 gNext, dNext;
        evalSoftBody(rest + vec2(0.078, 0.0), t, stiff, amp, gNext, dNext);
        if (iy == 0 || iy == 4) {
          goalHull = max(goalHull, smoothstep(px * 2.5, px * 0.6, sdSeg(uv, gPos, gNext)));
        }
      }
      if (iy < 4) {
        vec2 gNext, dNext;
        evalSoftBody(rest + vec2(0.0, 0.078), t, stiff, amp, gNext, dNext);
        if (ix == 0 || ix == 4) {
          goalHull = max(goalHull, smoothstep(px * 2.5, px * 0.6, sdSeg(uv, gPos, gNext)));
        }
      }
    }
  }

  // Smooth gelatin soft-body metaball fill colored by local displacement from rigid goal
  float mask = smoothstep(0.32, 0.58, bodyField);
  if (mask > 0.005) {
    float avgDisp = clamp((dispSum / max(bodyField, 1e-4)) * 12.0, 0.0, 1.0);
    vec3 softCol = mix(vec3(0.10, 0.66, 0.82), vec3(0.98, 0.52, 0.18), avgDisp);
    float rim = smoothstep(0.95, 0.36, bodyField);
    vec3 shaded = softCol * (0.62 + 0.38 * smoothstep(-0.35, 0.25, uv.y)) + vec3(0.85, 0.96, 1.0) * rim * 0.42;
    col = mix(col, shaded, mask * 0.86);
  }

  // Overlay best-fit rigid goal frame (R * q_i + c), goal positions, and pull arrows
  col = mix(col, vec3(0.98, 0.84, 0.32), goalHull * 0.72 * min(goalVis, 1.2));
  col = mix(col, vec3(1.0, 0.92, 0.45), smoothstep(0.011, 0.005, minGoal) * 0.75 * min(goalVis, 1.2));
  col += vec3(0.96, 0.42, 0.78) * pullLine * 0.85 * min(goalVis, 1.2);
  col = mix(col, vec3(0.92, 0.98, 1.0), smoothstep(0.016, 0.007, minDef) * 0.88);

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

Attribution: MIT — written for this index.

## Combination ideas

- [Concavity-aware deformable clusters via CoACD and shape matching](https://texelatlas.vercel.app/ideas/coacd-cluster-shape-matching/)

## Sources

1. [primary] Matthias Müller, Bruno Heidelberger, Matthias Teschner, Markus Gross (2005) Meshless deformations based on shape matching. ACM Transactions on Graphics. https://doi.org/10.1145/1073204.1073216 (verified via crossref on 2026-11-29)

## Cite this entry

Texel. "Shape matching (meshless deformation)." https://texelatlas.vercel.app/t/shape-matching-deformation/ (accessed 2026-12-01).
