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 two forms differ by 39%. Left: a lerped capsule. Right: the uneven capsule. The cyan line is an outline at a fixed distance.

Watch the cyan outline, which is drawn at one fixed distance from the surface in both halves. On the right it holds a constant width the whole way along. On the left it is fat at the wide end and pinched at the tip, because 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, and the answer is off by a factor related to the cone's slope. 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 outline at a fixed distance. Varying width means 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