ComputeBufferColorSource

← prev index next →

Paints a material's base color from a GPU-computed table of positioned color stops, looked up by a field's spatial weight — the escape hatch for a spatial color no built-in source computes, driven straight from a compute buffer with zero copy, with each color placed at its OWN parametric position.

Remarks

This is the GPU-computed member of the ColorSource family: like every color-source it gives a material a base color that varies across the surface, but the colors come from a table a compute node produces on the GPU rather than from a color-map, an image, or a procedural formula. It is the GPU-computed analogue of sk-ramp-color-map: each record is a (offset, color) stop, and an intensity-field DRIVER supplies a [0,1] weight from where a point is that is resolved against those stops the same way a ramp resolves its authored <sk-color-stop> offsets — find the bracketing pair by position and interpolate. Because each stop carries its own offset, the table can be non-uniformly spaced: dense stops in one region, sparse in another, or a sharp feature at an arbitrary position — an addressing a fixed i/(count-1) grid cannot express. A spherical, linear, or composite field addresses the table radially, directionally, or carved, exactly as it would drive a color-map.

Key attributes. compute-node (required) references the producing sk-compute-node by id; the node must declare output-kind="color-stops". compute-property-key selects which of its outputs to read (default output.0); alpha-mode declares how the sampled records' alpha is classified. intensity-field is the DRIVER whose [0,1] weight is looked up against the stops; field (from the ColorSource base) is the APPLICABILITY mask — where the source shows versus the flat base-color. Both fields follow the same absence convention: an omitted intensity-field drives the weight to 1 (the LAST stop's color), and an omitted field applies the source at full weight everywhere.

Stop contract. Each record is 32 bytes — an offset vec4<f32> (the [0,1] position in .x) and a color vec4<f32> (straight-alpha RGBA in linear space), bound zero-copy from the producer's buffer. Offsets must be a finite, monotonically non-decreasing sequence in [0,1]; the producing kernel emits them sorted (the lookup does NOT sort on the GPU, so out-of-order data yields undefined placement). A weight below the first offset or above the last clamps to that endpoint stop's color; coincident offsets produce a hard step. The lookup honors up to 100 stops. When the producer re-dispatches continuously, the source keeps the scene re-rendering.

Related. Its producer is a sk-compute-node (see AbstractComputeNode); its driver is any Field (sk-linear-gradient-field, sk-spherical-gradient-field, sk-composite-field, …). A material selects the source with base-color-source="#id" (see sk-plain-material). Its CPU-authored counterpart with arbitrary offsets is sk-ramp-color-map + sk-color-stop; its field-driven color-map sibling is sk-color-map-source; for hand-written per-fragment color instead of a precomputed table, use sk-custom-wgsl-color-source.

Constructor

constructor(config?: { computeNode?: AbstractComputeNode; computePropertyKey?: string; alphaMode?: CustomWGSLAlphaMode })

Properties

Config Properties

PropertyTypeDefaultDescriptionDeclared by
computeNodeanimatable AbstractComputeNode The directly referenced compute node, or null. ComputeBufferColorSource
computePropertyKey string "output.0" The computed-property key read from the referenced compute node ComputeBufferColorSource
alphaMode CustomWGSLAlphaMode "auto" Author-declared alpha classification of the sampled records (collect / ComputeBufferColorSource

Other Properties

PropertyTypeDefaultDescriptionDeclared by
intensityFieldanimatable Field | null Gets the driver field feeding the [0,1] scalar the concrete source turns DriverFieldColorSource
fieldanimatable Field | null Gets the optional applicability field that masks where this source ColorSource
visualize boolean false Whether the visualization is visible (wireframe splines + center marker). VisualizableSceneNode
xanimatable number 0 Gets the X position component. SceneNode
yanimatable number 0 Gets the Y position component. SceneNode
zanimatable number 0 Gets the Z position component. SceneNode
hanimatable number 0 Gets the heading (Y-axis) rotation in radians. SceneNode
panimatable number 0 Gets the pitch (X-axis) rotation in radians. SceneNode
banimatable number 0 Gets the bank (Z-axis) rotation in radians. SceneNode
quaternionanimatable Quaternion Gets the rotation as a quaternion. SceneNode
sxanimatable number 1 Gets the X-axis scale factor. SceneNode
syanimatable number 1 Gets the Y-axis scale factor. SceneNode
szanimatable number 1 Gets the Z-axis scale factor. SceneNode
hRad number 0 Gets the heading (Y-axis) rotation in radians. SceneNode
pRad number 0 Gets the pitch (X-axis) rotation in radians. SceneNode
bRad number 0 Gets the bank (Z-axis) rotation in radians. SceneNode
hDeg number 0 Gets the heading (Y-axis) rotation in degrees. SceneNode
pDeg number 0 Gets the pitch (X-axis) rotation in degrees. SceneNode
bDeg number 0 Gets the bank (Z-axis) rotation in degrees. SceneNode
xBasebase value number Gets the base (non-animated) value of X position. SceneNode
yBasebase value number Gets the base (non-animated) value of Y position. SceneNode
zBasebase value number Gets the base (non-animated) value of Z position. SceneNode
hBasebase value number 0 Gets the base (non-animated) value of heading (Y-axis rotation). SceneNode
pBasebase value number 0 Gets the base (non-animated) value of pitch (X-axis rotation). SceneNode
bBasebase value number 0 Gets the base (non-animated) value of bank (Z-axis rotation). SceneNode
quaternionBasebase value Quaternion Gets the base (non-animated) quaternion rotation. SceneNode
sxBasebase value number Gets the base (non-animated) value of X-axis scale. SceneNode
syBasebase value number Gets the base (non-animated) value of Y-axis scale. SceneNode
szBasebase value number Gets the base (non-animated) value of Z-axis scale. SceneNode
draggable boolean false Gets whether this node can be dragged. SceneNode
parentread-only SceneNode | null The parent node in the scene graph, or null at the root. SceneNode
sceneread-only any Gets the Scene this node belongs to, if any. SceneNode
posread-only Point3D Gets the world-space position of this node. SceneNode
matrixread-only Float32Array<ArrayBufferLike> Gets the computed 4x4 transformation matrix. SceneNode
animationsread-only SkenraAnimation[] Public getter for the animations affecting this target. SkenraAnimatable

Methods

MethodDescriptionDeclared by
addMaterialPaint(material: Material, paintTarget: PaintTarget, options?: any): Paint Applies a material to this node for a specific paint target. SceneNode
getPaints(): ReadonlyMap<PaintTarget, Paint> SceneNode
getOwnPaints(): readonly Paint[] Gets only the paints directly applied to this node (not inherited). SceneNode
removePaint(paint: Paint): void Removes a paint from this node. SceneNode
getWorldPosition(): number[] Returns this node’s origin in world space. SceneNode
getWorldMatrix(): Float32Array<ArrayBufferLike> Returns this node’s world transform — its local transform composed with all ancestor transforms. SceneNode
setViewportPosition(camera: AbstractCamera, x: number, y: number, z: number = 0.5): boolean Sets the node's local translation so that it appears at the specified viewport position. SceneNode
getViewportPosition(camera?: AbstractCamera): [number, number, number] | null Returns the node's current world position projected to viewport CSS pixel coordinates. SceneNode
setNDCPosition(camera: AbstractCamera, ndcX: number, ndcY: number, ndcZ: number = 0.5): boolean Sets the node's local translation so that it appears at the specified NDC position in the viewport. SceneNode
getBoundsInSpace(targetSpaceMatrix: Float32Array): { minX: number; maxX: number; minY: number; maxY: number; minZ: number; maxZ: number; } | null Computes the axis-aligned bounding box (AABB) of this node and its descendants SceneNode
animate(firstArg: TypedKeyframe<this>[] | TypedPropertyIndexedKeyframes<this> | Record<string, any> | globalThis.Keyframe[] | globalThis.PropertyIndexedKeyframes | null, secondArg?: number | KeyframeAnimationOptions | globalThis.KeyframeAnimationOptions): SkenraAnimation & Animation Creates a new SkenraAnimation for this target per Web Animations API. SkenraAnimatable
removeAnimation(animation: SkenraAnimation): boolean Removes a specific animation from this object. SkenraAnimatable
constrain(type: K, config: ConstraintConfigMap[K]): ConstraintReturnMap[K] Creates a constraint on this Animatable using a fluent API. SkenraAnimatable