Skip to content
This is the alpha v4 version website. Looking for the v3 documentation?

GLSL_SDF_ROUNDED_BOX

const GLSL_SDF_ROUNDED_BOX: ā€œ\nfloat sdfRoundedBox(vec2 p, vec2 halfSize, float radius) {\n vec2 d = abs(p) - halfSize + radius;\n return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0) - radius;\n}\nā€

Defined in: packages/sigma/src/rendering/glsl.ts:93

SDF for an axis-aligned rounded box. Shrinks box by radius, computes box SDF, subtracts radius. When radius=0, equivalent to sdfBox.