FragmentLayer
Defined in: packages/sigma/src/rendering/nodes/types.ts:313
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
Section titled “Properties”attributes
Section titled “attributes”attributes:
AttributeSpecification[]
Defined in: packages/sigma/src/rendering/nodes/types.ts:328
Additional per-node attributes required by this layer beyond standard attributes (position, size, color, id, zIndex).
glsl:
string
Defined in: packages/sigma/src/rendering/nodes/types.ts:351
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?
Section titled “lifecycle?”
optionallifecycle?: (context) =>LayerLifecycleHooks
Defined in: packages/sigma/src/rendering/nodes/types.ts:360
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
Section titled “Parameters”context
Section titled “context”Returns
Section titled “Returns”name:
string
Defined in: packages/sigma/src/rendering/nodes/types.ts:317
Unique identifier for this layer (e.g., “fill”, “border”).
uniforms
Section titled “uniforms”uniforms:
UniformSpecification[]
Defined in: packages/sigma/src/rendering/nodes/types.ts:322
Additional uniforms required by this layer beyond standard node uniforms.