| type | Algorithm | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| title | Blended solids | ||||||||||||||||||||||||||||
| description | Organic shapes — a figure, cloth over limbs — made of round cones, ellipsoids and boxes blended by a signed distance field and meshed by surface nets, painted by the piece nearest each point or by paint volumes. | ||||||||||||||||||||||||||||
| resource | https://github.com/smichea/osage/blob/main/crates/osage-procedural/src/sculpt.rs | ||||||||||||||||||||||||||||
| licence | MIT OR Apache-2.0 | ||||||||||||||||||||||||||||
| status | draft | ||||||||||||||||||||||||||||
| tags |
|
||||||||||||||||||||||||||||
| sources |
|
||||||||||||||||||||||||||||
| generated |
|
A figure assembled from capsules and spheres shows a seam and a crease at every joint: the shoulder is a ball stuck on a tube, and the whole reads as a mannequin. Modelling a figure by hand needs an artist and a licence; a world wants many, in many liveries, generated.
Describe the figure as a signed distance field — negative inside — made of simple pieces, and join the pieces with a smooth minimum instead of a plain one, so that where two pieces meet the surface fills the corner as flesh under cloth does1. Then mesh the field's zero level once2.
- Pieces3: a round cone from
a(radiusra) tob(radiusrb) for limbs and the neck; an ellipsoid, turned, for the pelvis, belly, chest and hands; a turned box, its edges rounded byr(the distance to the box shrunk byr, minusr): moulded plastic. Each piece belongs to a group (what the surface is there: suit, glove, boot). - Blend: the field is the pieces' distances folded with
smin(a, b, k) = min(a, b) − h²k/4,h = max(k − |a − b|, 0)/k;kis how far pieces blend (4.5 cm for a driver). Far from a joint it changes nothing. - Folds: a piece may ripple: its distance minus
depth · sin(105·s + 1.7·sin(2θ + 31·s)),salong its axis andθaround it — ridges about 6 cm apart, a few millimetres deep, wavering so that no two are alike, as a sleeve gathers at the elbow. - Mesh by surface nets: sample the field on a grid of cells (1.2 cm for a driver) over the pieces' boxes and a margin. In every cell whose corners differ in sign, place one vertex at the mean of the points where the field crosses the cell's twelve edges (linear interpolation). For every grid edge the surface crosses, join the vertices of the four cells around it in a quad, ordered counter-clockwise seen from the outside (the end of the edge that is inside tells which way that is); split each quad along its shorter diagonal.
- Normals from the field's gradient by central differences at each vertex: smooth, and they carry the folds even where the grid is too coarse to.
- Skin (for a figure that moves): each piece names a bone; a vertex takes the bone of the nearest solid piece and, within the blend of it, the next bone's too, weighted
0.5 − (d₂ − d₁)/2kfor the second (dthe distances to the bones' nearest pieces): halfway at a joint, one bone a blend away from it. The meshes carry joint indices and weights for a renderer's skinning. - Paint: a triangle takes the group of a paint volume (a cone or box that adds no matter, as a panel is sewn on a suit) that contains its centre — the last listed wins — otherwise the group of the solid piece nearest its centre. Each group becomes its own mesh, so that each can have its material and colour.
- Colours meet along the shapes' own edges (D-118). Surface nets put vertices where the cells are, so a paint volume's edge, cut triangle by triangle, is a row of teeth one cell long. Before the triangles are sorted: wherever an edge of the mesh joins vertices of two groups, the place along it where the group changes is found by bisection (seven steps), and the nearer of the two vertices is moved there — to the mean of such places when several of its edges cross, then back onto the surface along the field's gradient. Triangles then lie on one side or the other: a stripe's edge is a line at any cell size, for no triangle more.
In osage, a kart driver is 21 pieces and 10 paint volumes; sculpted once (the same body for every driver), each livery only paints its groups4.
Vertices lie on the surface within a cell; normals point outwards; at a joint two bones share a vertex half and half, away from it one bone has it whole; front faces face out; blending fills a corner and leaves far parts alone; paint adds no matter; folds are never deeper than asked. Tested.
The grid's points times the pieces, once: a driver at 1.2 cm (about 240 000 points, 21 pieces) takes a fraction of a second in a release build, a few seconds in a debug one. About 20 000 triangles. Measured at T3 on the Iris Xe, 2026-11-11, the race view: 127 ms per frame with the capsule drivers, 130 ms with the sculpted ones (the render bench).
- Pieces closer than the blend distance merge where they should not: fingers, legs held together. Keep separate parts more than
kapart, or blend with a smallerk. - A cell larger than a piece loses it; paint boundaries are as jagged as the cells.
- The ellipsoid's distance is approximate away from its surface: blending with it is slightly uneven.
Marching cubes (more triangles, sliver triangles, the same surface); dual contouring (keeps sharp edges, needs gradients); a sculpted or scanned mesh (best, when there is an artist and a licence); skinned capsules (cheap, but the creases remain).
The tests of sculpt.rs, and the render bench screenshots of the drivers.
Engine-independent: any figure, animal, rock or piece of cloth built from simple parts. The method is the classic one of signed distance fields; only the pieces and the paint rules are osage's.