Capsule line primitive — shared constants + CPU reference (issue #1352).
The capsule primitive draws a segment as a gaussian-like profile of the
2D POINT-TO-SEGMENT DISTANCE in pixel space, evaluated on interpolated
stencil-local coordinates. It exists because the screen-space quad's
near-axial behaviour is pathological (direction instability — the #790
sliver class) exactly where a distance-based profile is stable by
construction: end-on, the segment projects to a point and the profile
becomes a radial disc; the ribbon↔disc transition is continuous because
point-to-segment distance is continuous in the endpoints.
Three deliberate exactness relaxations (Loic, 2026-08-11 — "lines don't
have to be physics-exact, they need to behave reasonably: no pathological
near-axial drawing; any mathematically/computationally easier profile
that roughly looks gaussian"):
Quartic profile, not a gaussian.(1 − p²)^n with p = d/r and
the default knob at n = 2 — within ~12% of exp(−2p²) everywhere,
exactly 0 at the rim (compact support, no floor constants, no exp).
2σ support (the trim decision): the drawn radius is 2σ of the
equivalent gaussian, i.e. 2/T of the legacy quad half-width
(T = GAUSSIAN_EQUIVALENT_TRUNCATION ≈ 3.03σ, the 1%-of-peak floor).
Attributes interpolate across the stencil (colour/alpha/width/
sharpness as varyings evaluated at clamped corner positions) — the
blend stretches marginally into cap regions; sub-quantization.
Joints: EVERY end is a round cap; a partner-bearing interior end keeps
its HALF of the joint disc — the cap region (beyond the endpoint) is
partitioned along the joint's 2D BISECTOR line (normal =
normalize(q̂ − m̂) in pixel space, my side negative; the partner's normal
is the exact negation, so the two half-discs tile the disc exactly at any
bend angle). Which ends cut at all is the SHARED joint-code rule
(luxarLineJointCapSuppression): a free end and a degree-≥3 hub keep the
whole round cap — a hub has no single partner to tile against — while a
slice-clipped end is butt-cut. The cut spans the FULL joint plane (cap
and body) and composes by the DEFICIT rule over a 1 px AA RAMP: each
leg's fragment evaluates the plane in its own local frame, so a hard
step speckles — complementary ramps sum to exactly 1 and anti-alias the
cut for free — and on the partner's side each leg renders
max(mine − partner, 0), so the additive pair composes to
max(mine, partner). For congruent legs at a turn of 120° or less the
congruence gate (CAPSULE_JOINT_DEFICIT_GATE) keeps the packet empty and
the cut is an exact zero-double-count partition — the same domain
partition the deleted volumetric primitive integrated per ray; past 120° even
congruent legs need a live packet, since the bisector then cuts each rod
lengthwise (#1501, and #1495 below the width gate). Where the partner tapers away
or its apparent radius diverges under perspective, the deficit term
contributes exactly the light a pure partition would chop (a fat
vertex's disc keeps the half a thin neighbour cannot render). The
partner's field is rebuilt per fragment from the cut varying's packed
radius gradient + projected length and the shared-vertex radius
(the packed vPack.z lane, unpacked as pkR, #1494), with the far cap
closing the rod (#1490); the stencil reserves the full disc when a
packet exists, the deficit being bounded by my own profile, so a
half-disc reach there would leave the rasterizer chopping the very light
the deficit rule adds back (#1488). The partner's far endpoint is
near-plane-clipped toward the joint vertex before projecting (a
behind-eye projection flips and poisons the cut normal). A CPU model of
this composition — the joint-end STENCIL REACH included, since a
shortfall there is invisible to a model that evaluates the profile
everywhere — lives at the bottom of this file; the unit sweep
asserts the rendered pair tracks max(mine, partner).
Capsule line primitive — shared constants + CPU reference (issue #1352).
The capsule primitive draws a segment as a gaussian-like profile of the 2D POINT-TO-SEGMENT DISTANCE in pixel space, evaluated on interpolated stencil-local coordinates. It exists because the screen-space quad's near-axial behaviour is pathological (direction instability — the #790 sliver class) exactly where a distance-based profile is stable by construction: end-on, the segment projects to a point and the profile becomes a radial disc; the ribbon↔disc transition is continuous because point-to-segment distance is continuous in the endpoints.
Three deliberate exactness relaxations (Loic, 2026-08-11 — "lines don't have to be physics-exact, they need to behave reasonably: no pathological near-axial drawing; any mathematically/computationally easier profile that roughly looks gaussian"):
(1 − p²)^nwithp = d/rand the default knob at n = 2 — within ~12% ofexp(−2p²)everywhere, exactly 0 at the rim (compact support, no floor constants, noexp).2/Tof the legacy quad half-width (T = GAUSSIAN_EQUIVALENT_TRUNCATION ≈ 3.03σ, the 1%-of-peak floor).Joints: EVERY end is a round cap; a partner-bearing interior end keeps its HALF of the joint disc — the cap region (beyond the endpoint) is partitioned along the joint's 2D BISECTOR line (normal = normalize(q̂ − m̂) in pixel space, my side negative; the partner's normal is the exact negation, so the two half-discs tile the disc exactly at any bend angle). Which ends cut at all is the SHARED joint-code rule (
luxarLineJointCapSuppression): a free end and a degree-≥3 hub keep the whole round cap — a hub has no single partner to tile against — while a slice-clipped end is butt-cut. The cut spans the FULL joint plane (cap and body) and composes by the DEFICIT rule over a 1 px AA RAMP: each leg's fragment evaluates the plane in its own local frame, so a hard step speckles — complementary ramps sum to exactly 1 and anti-alias the cut for free — and on the partner's side each leg renders max(mine − partner, 0), so the additive pair composes to max(mine, partner). For congruent legs at a turn of 120° or less the congruence gate (CAPSULE_JOINT_DEFICIT_GATE) keeps the packet empty and the cut is an exact zero-double-count partition — the same domain partition the deleted volumetric primitive integrated per ray; past 120° even congruent legs need a live packet, since the bisector then cuts each rod lengthwise (#1501, and #1495 below the width gate). Where the partner tapers away or its apparent radius diverges under perspective, the deficit term contributes exactly the light a pure partition would chop (a fat vertex's disc keeps the half a thin neighbour cannot render). The partner's field is rebuilt per fragment from the cut varying's packed radius gradient + projected length and the shared-vertex radius (the packedvPack.zlane, unpacked aspkR, #1494), with the far cap closing the rod (#1490); the stencil reserves the full disc when a packet exists, the deficit being bounded by my own profile, so a half-disc reach there would leave the rasterizer chopping the very light the deficit rule adds back (#1488). The partner's far endpoint is near-plane-clipped toward the joint vertex before projecting (a behind-eye projection flips and poisons the cut normal). A CPU model of this composition — the joint-end STENCIL REACH included, since a shortfall there is invisible to a model that evaluates the profile everywhere — lives at the bottom of this file; the unit sweep asserts the rendered pair tracks max(mine, partner).