The tapered limb is not a lerped capsule

Limbs taper, so the obvious primitive is a capsule whose radius interpolates from one end to the other. It is two extra characters, it draws a convincing tapered shape, and it does not return a distance.

A short, steeply tapered limb: slope 0.79, where the lerped field overstates distance by 27%. Left: a lerped capsule. Right: the uneven capsule. The cyan line is where each field reads a fixed distance inside.

Watch the bands and the cyan line. Both are drawn from the field, so both show what it reports. On the right the bands are evenly spaced offsets of the shape all the way out, and the cyan line, drawn where the field reads 0.075 inside, sits the same distance in from the edge the whole way round. On the left the bands kink and bunch along the tapered sides, the cyan line hugs the edge more closely along the sides than around the round end, and the silhouette itself has corners where the cone meets the caps. The field is reporting the wrong distance, and anything reading that distance inherits the error.

Why the lerp fails

A capsule works by projecting onto its axis and subtracting a radius. That is exact while the radius is constant, because the nearest point on the surface really is directly out from the axis.

Taper it and the surface becomes a cone, tilted relative to the axis. The nearest point on a tilted surface is no longer straight out from the axis, so the projection lands in the wrong place. Along the taper the lerped field changes by sqrt(1 + s*s) per unit of distance, s being the slope, so it reads that much too far: 2% on a gentle arm, 27% on the limb above. Gentle tapers hide it. Strong ones do not, which is why this survives on arms and falls apart the moment someone models a horn or a tail.

The correct primitive already exists

The uneven capsule is the published closed form for exactly this shape. Its key term is dot(p, vec2(a, b)) - r1, a projection onto the sloped surface where b is the taper slope, rather than onto the axis. Two branches and a sqrt, and it is correct.

The same reasoning applies anywhere a parameter varies along a primitive. Sweeping a radius, a width or a thickness along a shape almost always breaks the distance property unless the closed form was derived for the swept version.

What it costs you to get wrong

Rules of thumb

  1. Do not lerp a radius along a capsule. Use a round cone.
  2. Test a primitive with a STRONG taper. A gentle one hides the error.
  3. Draw an isoline a fixed distance inside. If it does not sit the same distance in from the edge all the way round, the field is wrong.
  4. Any parameter varying along a primitive is suspect until the closed form says otherwise.
  5. If a limb's rim light pumps thicker and thinner along its length, this is why.

All 61 notes How to use them Credits

If you find anything wrong, let me know at hello@andrewdetwiler.com and I'll get it updated.