Documentation / Node reference / code nodes
code/SDFBox2D
The distance to a rectangle, with square, rounded or chamfered corners.
Sdf2d
Returns the signed distance from a sampled position to a rectangle in the plane. The twin of geo/SDFBox2D, for use inside a geo/SDFBuilder sub-network.
Set `bevel` to ROUND or CHAMFER to round or cut the corners. The cut goes into the rectangle, so its sides stay where they were. Every corner can have its own size: `bevelSize` sets all four, and `cornerSizes` adds to it corner by corner. The distance stays exact either way.
Parameters
| Name | Type | What it does |
|---|---|---|
| P | Vector2 | Position to sample the field at. Left unwired it reads the builder's own sample position. |
| t | Vector2 | Rectangle center. |
| size | Vector2 | Rectangle size per axis, multiplied by `scale`. |
| scale | Float | Uniform scale applied to `size`, and to the bevel sizes. |
| bevel | UInt8 NONE · ROUND · CHAMFER | How the corners are shaped: NONE leaves them square, ROUND rounds them, CHAMFER cuts them off straight. |
| bevelSize | Float | Bevel size of all four corners: the radius of a round corner, or how far a chamfer reaches along each side. A corner never grows past half the shorter side. |
| cornerSizes | Vector4 | Added to `bevelSize`, one corner at a time, going round from the top right: x is top right, y top left, z bottom left, w bottom right. Negative values shrink a corner, down to square. |
See also
- geo/SDFBox2D
- code/SDFCircle2D
- code/SDFBoolean
This page is generated from the engine, so it describes the release you can download. The same text is in the editor's Help panel next to the node itself.