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

FragmentLayer

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

Definition of a fragment layer that can be composed with a shape. Layers output a color that is blended with previous layers by the generator.

Properties

attributes

attributes: AttributeSpecification[]

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

Additional per-node attributes required by this layer beyond standard attributes (position, size, color, id, zIndex).


glsl

glsl: string

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

GLSL function code that applies this layer’s effect.

Function signature: vec4 layer_{name}(…layerParams)

where layerParams are: attributes (as v_* varyings), then uniforms.

Available globals:

  • context.sdf: Signed distance field value (negative inside, 0 at boundary, positive outside)
  • context.uv: Normalized coordinates in [-1, 1] range
  • context.shapeSize: Effective shape radius in UV space (1.0 - context.aaWidth)
  • context.aaWidth: Antialiasing width in UV space for smooth internal transitions
  • context.pixelSize: Node diameter in screen pixels (for pixel-mode calculations)
  • context.correctionRatio: Scaling factor for consistent rendering across zoom levels
  • context.pixelToUV: Conversion factor from screen pixels to UV units

The function should return a vec4 color for this layer’s contribution. Transparent areas (alpha < 1) let previous layers show through. The generator handles blending via “over” compositing.


lifecycle?

optional lifecycle?: (context) => LayerLifecycleHooks

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

Optional lifecycle factory for layers that need async resources (like textures). Called once per program instance with the lifecycle context. Returns lifecycle hooks for this layer instance.

Layers without this property work as before (purely declarative).

Parameters

context

LayerLifecycleContext

Returns

LayerLifecycleHooks


name

name: string

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

Unique identifier for this layer (e.g., “fill”, “border”).


uniforms

uniforms: UniformSpecification[]

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

Additional uniforms required by this layer beyond standard node uniforms.