gather

Write your own gather effect: a function that can read the child anywhere.

gather(config: Omit<GatherEffect, 'kind'>): GatherEffect

Import gather from shaders/std.

Give it build, which receives the child as a texture (params.texture, or params.sampleStraight(uv) for plain colors), params.ctx.uv for this pixel and params.uniforms for your props. Return the new color. Set resultAlpha: 'straight' when you built the color from sampleStraight. Costs one extra render of the child.

Parameters

NameTypeNotes
configOmit<GatherEffect, 'kind'>

Example

effect: gather({resultAlpha: 'straight', build: ({sampleStraight, ctx, uniforms}) => sampleStraight(math.add(ctx.uv, uniforms.shift))})

Tip. Reach for pointwise first. Only gather when the effect needs pixels other than this one.

See also

  • pointwise — Write your own pointwise effect: a function of the child's color at this pixel.
  • displaceBy — Push the child's pixels around by a vector field from one of your simulations.