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.
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
- Outlines and glows sit at the wrong inset and change it along the limb, which is the visible tell.
- Blends land in the wrong place, since
smincompares distances and one of them is lying. - Bevels and rim lights ride the wrong isoline, so the shading thickness pumps along the taper.
- Marching oversteps along the taper, because the field reads long there.
Rules of thumb
- Do not lerp a radius along a capsule. Use a round cone.
- Test a primitive with a STRONG taper. A gentle one hides the error.
- 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.
- Any parameter varying along a primitive is suspect until the closed form says otherwise.
- If a limb's rim light pumps thicker and thinner along its length, this is why.
If you find anything wrong, let me know at hello@andrewdetwiler.com and I'll get it updated.
One email when something new goes up. No newsletter, no schedule, nothing else.
Double opt-in, so watch for a confirmation email. Unsubscribe any time.