Discrete elastic rods (hair and rope simulation)
Treat hair, rope or cable as a chain of edges with a material frame per edge; bending and twisting energies come from curvature and twist of the discrete curve, giving physically meaningful stiffness.
Also known as DER, Cosserat rods, elastic rod model
In the family Simulation & animation, rods & hair
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 | None found | |
| Unity | None found | |
| Unreal 5.7 | None found | |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
A rod is a polyline of vertices with an orthonormal material frame attached to every edge. The state is vertex positions plus one twist angle per edge. Energies are written discretely: stretching from edge length, bending from the curvature binormal at each interior vertex computed in the two adjacent material frames, and twisting from the change in angle between consecutive frames after a parallel transport of the reference frame along the curve. Because the reference frame is propagated by parallel transport (the idea behind Rotation-Minimizing Frames), twist is measured as a scalar, avoiding frame singularities. Forces and Hessians follow by differentiating the energies; the system is integrated with implicit Euler or a variational scheme, and Newton iterations on a banded system keep the cost linear in segment count. Collisions, friction and contact with a body are handled with penalty or constraint terms around this core.
When to choose it
Reach for it when
- hair or rope needs real bending and twist stiffness
- curly strands coil naturally and hold their shape
- cable simulation with physically meaningful material parameters
- thin elastic strands blow up under stiff explicit integration
Choose it when physical fidelity of thin elastic structures matters: hair curls, coiling ropes, cables, sutures and sweaters at offline or interactive rates, where bending and twist stiffness have to be real material parameters. Prefer Verlet integration with relaxation constraints or Extended Position-Based Dynamics strands when stability, speed and artistic control matter more than physical units, and Position Based Dynamics for large hair counts in games. Prefer Implicit cloth integration (Baraff-Witkin) for two-dimensional sheets.
Field marks
- Stiff systems need implicit integration; explicit steps explode at realistic bending stiffness
- Frame twisting near straight segments loses the reference frame if parallel transport is not handled with care
- Self-collision between strands is expensive and often left to a separate contact model
- Newton solves can fail to converge at large timesteps or under strong contact
- Per-edge frames add state that game engines rarely store, complicating export
Presets
Discrete elastic rods — 3D Bishop-frame twisted helices, material-frame twist stripes & bend energy
{
"P_TWIST_RATE": 3.2,
"P_BEND_AMP": 0.42,
"P_ROD_RADIUS": 0.085,
"P_ANIM_SPEED": 1
}Show GLSL (144 lines)
const float P_TWIST_RATE = 3.2; // P Material Twist [0.5, 7.0, 0.1]
const float P_BEND_AMP = 0.42; // P Helical Buckling [0.1, 0.75, 0.02]
const float P_ROD_RADIUS = 0.085; // P Rod Thickness [0.04, 0.14, 0.005]
const float P_ANIM_SPEED = 1.0; // P Wave Speed [0.0, 2.5, 0.05]
mat2 rot2(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }
// Centerline of a buckled elastic rod parametrized by arc parameter s in [-1.4, 1.4]
vec3 rodCenter(float s, float rodId, float t, float bendAmp) {
float ph = rodId * 2.094395 + t * 0.85;
// Buckling envelope strongest in middle, clamped at endpoints
float env = cos(clamp(s * 0.95, -1.5708, 1.5708));
float rHelix = bendAmp * (0.35 + 0.65 * env * env);
float freq = 3.2 + 0.45 * sin(t * 0.5 + rodId);
return vec3(
s * 0.92,
rHelix * cos(s * freq + ph),
rHelix * sin(s * freq + ph)
);
}
// Evaluate distance to 3 intertwined elastic rods + return (dist, rodId, arcS, frameAngle)
vec4 mapRods(vec3 p, float t, float bendAmp, float rodRad) {
vec3 q = p;
q.xz = rot2(t * 0.25) * q.xz;
q.yz = rot2(0.28) * q.yz;
float bestD = 1e5;
float bestId = 0.0;
float bestS = 0.0;
float bestPhi = 0.0;
for (int r = 0; r < 3; r++) {
float fr = float(r);
// Approximate nearest arc-length parameter s via 2-step Newton projection from q.x
float s = clamp(q.x / 0.92, -1.35, 1.35);
for (int k = 0; k < 2; k++) {
vec3 c0 = rodCenter(s, fr, t, bendAmp);
vec3 c1 = rodCenter(s + 0.015, fr, t, bendAmp);
vec3 tang = normalize(c1 - c0);
float ds = dot(q - c0, tang) * 0.62;
s = clamp(s + ds, -1.35, 1.35);
}
vec3 c = rodCenter(s, fr, t, bendAmp);
vec3 cNext = rodCenter(s + 0.02, fr, t, bendAmp);
vec3 T = normalize(cNext - c);
// Parallel-transported Bishop reference frame (U, V) orthogonal to tangent T
vec3 upRef = vec3(0.0, 1.0, 0.0);
vec3 U = normalize(cross(T, upRef) + vec3(0.0, 0.0, 1e-4));
vec3 V = cross(T, U);
vec3 rel = q - c;
float d = length(rel) - rodRad;
if (d < bestD) {
bestD = d;
bestId = fr;
bestS = s;
bestPhi = atan(dot(rel, V), dot(rel, U));
}
}
return vec4(bestD * 0.78, bestId, bestS, bestPhi);
}
vec3 calcNormal(vec3 p, float t, float bendAmp, float rodRad) {
vec2 e = vec2(0.0025, 0.0);
return normalize(vec3(
mapRods(p + e.xyy, t, bendAmp, rodRad).x - mapRods(p - e.xyy, t, bendAmp, rodRad).x,
mapRods(p + e.yxy, t, bendAmp, rodRad).x - mapRods(p - e.yxy, t, bendAmp, rodRad).x,
mapRods(p + e.yyx, t, bendAmp, rodRad).x - mapRods(p - e.yyx, t, bendAmp, rodRad).x
));
}
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 tAnim = iTime * max(P_ANIM_SPEED, 0.0);
float twist = clamp(P_TWIST_RATE, 0.2, 8.0);
float bendAmp = clamp(P_BEND_AMP, 0.08, 0.85);
float rodRad = clamp(P_ROD_RADIUS, 0.035, 0.16);
vec3 ro = vec3(0.0, 0.08, 2.55);
vec3 rd = normalize(vec3(uv, -1.55));
// Studio slate background
vec3 col = mix(vec3(0.03, 0.04, 0.068), vec3(0.09, 0.115, 0.165), 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;
vec4 hitRes = vec4(0.0);
bool hit = false;
for (int i = 0; i < 68; i++) {
vec4 h = mapRods(ro + rd * t, tAnim, bendAmp, rodRad);
if (h.x < 0.002) { hit = true; hitRes = h; break; }
t += h.x;
if (t > 8.5) break;
}
if (hit) {
vec3 p = ro + rd * t;
vec3 n = calcNormal(p, tAnim, bendAmp, rodRad);
float rodId = hitRes.y;
float s = hitRes.z;
float phi = hitRes.w;
// Material frame angle theta(s) rotates relative to the twist-free Bishop frame!
float matAngle = phi - s * twist * 2.2 - tAnim * 1.4;
float twistStripe = smoothstep(-0.12, 0.12, sin(matAngle * 2.0));
// Discrete vertex segment rings along the elastic rod polyline
float segRing = smoothstep(0.075, 0.015, abs(fract(s * 6.5) - 0.5));
// Curvature energy glow highest near high-buckling midspan
float bendEnergy = cos(clamp(s * 0.95, -1.5708, 1.5708));
bendEnergy = bendEnergy * bendEnergy * clamp(bendAmp * 1.8, 0.0, 1.0);
vec3 baseA, baseB;
if (rodId < 0.5) {
baseA = vec3(0.16, 0.62, 0.92); baseB = vec3(0.96, 0.82, 0.32);
} else if (rodId < 1.5) {
baseA = vec3(0.92, 0.34, 0.28); baseB = vec3(0.96, 0.92, 0.86);
} else {
baseA = vec3(0.18, 0.82, 0.58); baseB = vec3(0.14, 0.24, 0.38);
}
vec3 alb = mix(baseA, baseB, twistStripe);
alb = mix(alb, vec3(0.06, 0.08, 0.12), segRing * 0.45);
vec3 l1 = normalize(vec3(0.62, 0.85, 0.58));
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), 46.0) * 0.65;
float rim = pow(1.0 - max(dot(n, -rd), 0.0), 2.8) * 0.38;
col = alb * (0.24 + 0.86 * diff1 + 0.25 * diff2) + vec3(spec) + vec3(0.55, 0.78, 1.0) * rim;
col += vec3(1.0, 0.52, 0.18) * bendEnergy * 0.16;
}
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 |
|---|---|---|---|
| discrete-elastic-rods-live | Tesla T4 1920x1080 | 161× baseline (extreme) · 5.06 ms / 5.20 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| discrete-elastic-rods-live | NVIDIA L4 1920x1080 | 148× baseline (extreme) · 2.34 ms / 2.42 ms · 2.2× faster on L4 | opengl-timer-query · Cross-architecture validation |
| discrete-elastic-rods-live | NVIDIA A100-SXM4-40GB 1920x1080 | 107× baseline (extreme) · 3.07 ms / 3.16 ms · 1.6× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites Stable Fluids.
Crosses
- Rotation-Minimizing Frames: Parallel-transported reference frames along the rod give the twist measure the elastic energy needs.
Sources
- primaryMiklós Bergou, Max Wardetzky, Stephen Robinson, Basile Audoly, Eitan Grinspun (2008). Discrete elastic rods. ACM Transactions on Graphics.Verified via crossref · 2026-11-29doi:10.1145/1360612.1360662
- primaryMiklós Bergou, Basile Audoly, Etienne Vouga, Max Wardetzky, Eitan Grinspun (2010). Discrete viscous threads. ACM Transactions on Graphics.Verified via crossref · 2026-11-29doi:10.1145/1778765.1778853
- tutorialBergou, Wardetzky, Robinson, Audoly, Grinspun. Discrete Elastic Rods project page (Columbia Computer Graphics Group). cs.columbia.edu.Verified via live page · 2026-11-29
- implementationjpanetta (2019). jpanetta/ElasticRods. Elastic Rod and X-Shell SimulationGitHub API · license MIT · 2026-11-29