API

Interface ITextureProcessOperand

Represents an operand for a texture processing operation, or the result of one.

As an operand, the value evaluates to a vec4 per texel:

  • texture only → sample(texture)
  • factor only → factor (constant)
  • both → sample(texture) * factor

As a result returned by a processing function:

  • texture holds the GPU-processed output; dispose() releases it when no longer needed.
  • factor holds a CPU-folded constant when all inputs were texture-free; no dispose is set.

Results are directly usable as operands to subsequent operations. When a result with a dispose function is passed as an operand, the next operation automatically calls dispose after consuming it, so intermediate textures are cleaned up without manual tracking.

At least one of texture or factor must be provided when used as an operand.

interface ITextureProcessOperand {
    channel?: TextureChannel;
    colorSpace?: TextureColorSpace;
    dispose?: () => void;
    factor?: any;
    texture: Nullable<BaseTexture>;
}
Index
channel?: TextureChannel

Optional channel selection applied to the sampled texture value before any factor multiplication. When omitted or set to TextureChannel.RGBA, the sample is used as-is. When set to a single channel, that channel's scalar is broadcast to RGB (or all four components for TextureChannel.A). Only meaningful when texture is set.

colorSpace?: TextureColorSpace

Color space of the texture data. When set to TextureColorSpace.SRGB, the sampled RGB channels are converted from sRGB to linear space (IEC 61966-2-1) before the channel swizzle, factor multiplication, and any arithmetic operation. Alpha is always linear. Defaults to TextureColorSpace.Linear (no conversion). Only meaningful when texture is set.

dispose?: () => void

Disposes the texture produced by a processing operation. Only present on results returned by the texture processing functions. When a result is passed as an operand to the next operation in a chain, its dispose is called automatically after the GPU pass completes. Call dispose explicitly on the final result when the texture is no longer needed (or skip it if transferring ownership to a material).

factor?: any

Optional constant RGBA factor. If texture is also set, the sampled value is multiplied by this factor. If texture is not set, this becomes the constant output. When omitted and texture is set, defaults to (1, 1, 1, 1) — no scaling.

Texture to sample. When combined with factor, the sampled value is multiplied component-wise by the factor. Null when the operand or result is a constant.