pointwiseOp

Wrap a compiled GPU function as a pointwise filter effect: the child's color goes in first, then args.

pointwiseOp(
  fn: unknown,
  hint: string,
  args: ArgSpec[],
  extra?: {compose?: PointwiseEffect['compose']; setup?: PointwiseEffect['setup']},
): PointwiseEffect

Import pointwiseOp from shaders/std.

This is how the library's color words are made. fn takes (color: vec4f, ...args) and returns the new color; hint names it in the generated code; args are the values that follow the color, given as prop refs, scalars, context tokens or numbers. extra.compose post-processes the result and extra.setup runs once per build.

Parameters

NameTypeNotes
fnunknown
hintstring
argsArgSpec[]
extra{compose?: PointwiseEffect['compose']; setup?: PointwiseEffect['setup']}Optional.

Example

export function saturate(intensity: ArgSpec): PointwiseEffect {
  return pointwiseOp(colorOps.saturate, 'saturate', [intensity])
}

See also

  • resolveArg — Any input value a word accepts (a prop ref, a Scalar, a context token, a number) as a GPU value inside a filter's builder.
  • p — Reference one of the definition's props by name, wherever a word asks for a value.