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

LayerContext

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

Context provided to a fragment layer’s GLSL code via the global context struct. This struct is populated by the generator before calling any layer functions.

GLSL definition:

struct LayerContext {
float sdf; // Signed distance from shape boundary
vec2 uv; // UV coordinates [-1, 1]
float shapeSize; // Effective shape radius in UV space
float aaWidth; // Anti-aliasing width
float pixelSize; // Node diameter in screen pixels
float correctionRatio; // Scaling factor for consistent rendering
float pixelToUV; // Conversion: pixels * pixelToUV = UV units
};
LayerContext context; // Global instance

aaWidth: "float"

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

The antialiasing width in UV space. Use this for smooth transitions between internal borders/regions.


correctionRatio: "float"

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

Scaling factor for consistent rendering across zoom levels. Useful for advanced effects that need to compensate for camera zoom.


pixelSize: "float"

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

The node diameter in screen pixels. Useful for pixel-mode border calculations.


pixelToUV: "float"

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

Conversion factor from screen pixels to UV units. Multiply a pixel value by this to get the equivalent size in UV space. Use this for pixel-mode border sizes or any pixel-based measurements.


sdf: "float"

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

The signed distance field value at this fragment. Negative inside the shape, zero at boundary, positive outside.


shapeSize: "float"

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

The effective shape size in UV space (1.0 - aaWidth). This is the radius where the solid shape ends, before the AA band.


uv: "vec2"

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

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