Field Shape
Circles, Rectangles, Polygons and Stars as Exact Distance Fields
- reference_image
- reference_mask
- mask
- preview
- sdf
The mask generator you'll use for everything that isn't organic
Field Noise gives you pattern; Field Shape gives you geometry. A circle, a rectangle with rounded corners, a regular polygon, a star - as an exact signed distance field, positioned and sized in frame-relative units. If your workflow needs a vignette, a soft-edged circular falloff, a star burst mask, a rounded-rect region for a letterbox reveal, this is the node. And because it's an SDF, the soft edge is a real distance ramp rather than a blur, so it stays clean at any resolution.
Size means drawn size
size_x and size_y are the drawn half-extents along x and y before rotation, as a fraction of the longer frame edge. Typed size is what you get, for every shape - a polygon or star is normalised by its own bounding box, so 0.40 / 0.20 draws a shape that genuinely spans 0.40 by 0.20. That's the whole point of the reformulation this node went through: the old behaviour had you specifying a circumradius and then guessing what the drawn extent would be.
The flip side is worth knowing before you file it as a bug: a regular n-gon has a non-square bounding box, so equal sizes draw a slightly stretched one. A regular hexagon wants size_x = 0.866 × size_y; a regular pentagon wants size_y = 0.951 × size_x. Those are geometric facts about the shapes, not rounding.
Other geometry widgets: shape (circle, rect, polygon, star), rotation in degrees counter-clockwise (inert on a round circle - a circle is rotation-invariant, so there's nothing to rotate), center_x / center_y in window fractions, sides for polygons and stars (3 to 12), star_ratio for the star's inner/outer radius ratio, and corner_radius for rect.
Edges: falloff vs aa_width
Two separate controls and people conflate them. falloff is the authored soft edge - a quintic ramp in frame units, the edge you designed. aa_width is the rasterisation width in pixels, the antialiasing. They compose as widths, so antialiasing never blurs an authored edge, and a wide falloff makes aa_width a no-op. If you set a big falloff and then wonder why aa_width does nothing, that's the mechanism working.
The third output is the interesting one. sdf is the raw distance field, in Field Distance's both convention: contour at exactly 0.5, positive inside, clamped at sdf_range. That's a proper signed field, so Field Threshold at its default settings recovers the mask from it - never the complement. You can take the sdf output, feed it into Field Remap or Field Threshold, and get contours, bands, outlines and glows out of one shape without ever building a second generator.
Outputs: mask, preview (the mask as a 3-channel IMAGE), sdf.
Honest limits, measured
Hard edges hold up to a 200:1 size ratio with no pixel wrong by more than a quarter level - that's very good. But falloff and the sdf output ride a first-order distance correction that's accurate below about 4:1 and degrades gradually above it, worst near the tips of very elongated shapes. So a 0.40 × 0.05 thin rectangle gets an admittedly approximate soft edge. If you need a precise soft edge on a thin sliver, build it differently.
And sharp tips - a triangle corner, a thin star point - lose a couple of pixels of rendered extent to pixel-centre quantisation. The geometry is exact; the raster can only show pixels whose centres it covers. Don't go hunting for the missing point.
Install
ComfyUI Manager → ComfyUI Field, or:
cd ComfyUI/custom_nodes
git clone https://github.com/jeremieLouvaert/ComfyUI-Field
Restart ComfyUI. No downloads, no pip. Under AKURATE/Fields/Generate. Like the other generators it takes reference_image and reference_mask, so you can wire the image you're going to composite onto and have the shape come out at exactly the right size with no resize.
How it slots in
The usual pattern: shape → Field Morphology (feather) or a falloff value for the soft edge → Field Composite to spend it. Or shape → sdf → Field Threshold band for a contour stroke at any width. Or combine it with noise using Field Combine so your circular region has a rough, irregular boundary instead of a perfect arc - which is the moment a procedural mask stops looking procedural.
distribution, coverage and invert behave as everywhere else in the pack: native for the field's own range, uniform for the rank-transformed version where coverage is exact.
Inputs (19)
| Name | Type | Default | Description |
|---|---|---|---|
| shape | COMBO | circle | 4 options: circle, rect, polygon, star |
| size_x | FLOAT | 0.2500.01–2 | Drawn half-extent along x before rotation, fraction of frame S. Soft falloff and the sdf output are approximate on strongly elongated shapes (docs/field-phase2c-derivation.md 1.2) |
| size_y | FLOAT | 0.2500.01–2 | Drawn half-extent along y before rotation, fraction of frame S. Soft falloff and the sdf output are approximate on strongly elongated shapes (docs/field-phase2c-derivation.md 1.2) |
| rotation | FLOAT | 0-360–360 | Degrees, counter-clockwise. Inert for a round circle (size_x == size_y) |
| center_x | FLOAT | 0.50-1–2 | — |
| center_y | FLOAT | 0.50-1–2 | — |
| sides | INT | 53–12 | Polygon / star point count |
| star_ratio | FLOAT | 0.500.1–0.95 | Inner/outer radius ratio, star only. Clamped to the achievable range for `sides` (see console note) |
| corner_radius | FLOAT | 0.0000–0.5 | Rect only |
| falloff | FLOAT | 0.0000–1 | Authored soft edge width, fraction of S. 0 = hard |
| aa_width | FLOAT | 1.00–4 | Antialias width, pixels. No-op once falloff exceeds it |
| sdf_range | FLOAT | 0.2500.001–1 | Clamp range for the raw sdf output, fraction of S |
| distribution | COMBO | native | 2 options: native, uniform |
| coverage | FLOAT | 0.500–1 | — |
| invert | BOOLEAN | false | — |
| width | INT | 51216–8192 | — |
| height | INT | 51216–8192 | — |
| reference_imageopt | IMAGE | — | |
| reference_maskopt | MASK | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |
| preview | IMAGE | — |
| sdf | MASK | — |