Skip to content
sigma.js sigma.js
v4.0.6 Docs Examples GitHub 12.2K

SDFShape

Defined in: packages/sigma/src/rendering/nodes/types.ts:104

Definition of a Signed Distance Field shape. Shapes provide GLSL code that computes the signed distance from a point to the shape’s boundary (negative inside, 0 on boundary, positive outside).

optional attributes?: AttributeSpecification[]

Defined in: packages/sigma/src/rendering/nodes/types.ts:131

Per-node float attributes (e.g. a rectangle’s aspectRatio), read from the node attribute texture and passed to sdf_{name}() after the uniforms.


glsl: string

Defined in: packages/sigma/src/rendering/nodes/types.ts:119

GLSL function code that computes the signed distance field. Function signature: float sdf_{name}(vec2 uv, …) where … represents the shape-specific uniforms as additional parameters.

uv

Normalized coordinates in [-1, 1] range, (0, 0) at center

Signed distance (negative inside, 0 on boundary, positive outside)


optional inradiusFactor?: number

Defined in: packages/sigma/src/rendering/nodes/types.ts:149

Ratio of inradius to circumradius for this shape. This indicates how “deep” the shape goes relative to the bounding circle.

  • Circle: 1.0 (inradius equals circumradius)
  • Square: 1.0 (inscribed circle touches all sides)
  • Triangle: 0.5 (inradius is half the circumradius for equilateral)
  • Diamond: ~0.707 (√2/2 for a square rotated 45°)

Used by layers like border to correctly calculate fill sizes. Defaults to 1.0 if not specified.


optional inradiusFactorGLSL?: string

Defined in: packages/sigma/src/rendering/nodes/types.ts:155

GLSL expression replacing inradiusFactor in the node fragment shader, for shapes whose depth varies per node. Reads attributes as v_<name>.


name: string

Defined in: packages/sigma/src/rendering/nodes/types.ts:109

Unique identifier for this shape (e.g., “circle”, “square”). Used to generate the GLSL function name: sdf_{name}


uniforms: UniformSpecification[]

Defined in: packages/sigma/src/rendering/nodes/types.ts:125

Additional uniforms required by this shape (e.g., u_cornerRadius, u_rotation). Values are baked into the GLSL, so each set of values is its own shape instance.


optional variables?: Record<string, { default: string | number; type: "number" | "color"; }>

Defined in: packages/sigma/src/rendering/nodes/types.ts:136

Variables backing the attributes above, like EdgePath’s variables.