pipe(source, passes, [opt])
Run a source texture through one or more filter shaders in sequence and draw
the result on the canvas, or keep it off-screen and use the returned
framebuffer with display set to false (see the off-screen example). The two
working framebuffers are managed for you; key separates independent chains,
and ping/pong let you supply your own. Needs a WEBGL canvas, a source,
and filter shaders.
| Parameter | Type | Default | Description |
|---|---|---|---|
source |
p5.Framebuffer|p5.Texture|p5.Image|p5.Graphics |
Input texture; a Framebuffer contributes its .color. |
|
passes |
p5.Shader|p5.Shader[] |
A pass or array of passes (e.g. baseFilterShader().modify(...)); falsy entries ignored. |
|
opt optional |
Object |
Options. | |
opt.display optional |
boolean |
true |
If true, draw the final output to the main canvas. |
opt.allocate optional |
boolean |
true |
If true, create the two working framebuffers when missing (kept per key). |
opt.key optional |
string |
'default' |
Name of the working framebuffer pair; give each independent chain its own key. |
opt.ping optional |
p5.Framebuffer |
Your own first working framebuffer (advanced; not kept by pipe()). |
|
opt.pong optional |
p5.Framebuffer |
Your own second working framebuffer (advanced; not kept by pipe()). |
|
opt.clear optional |
boolean |
true |
If true, clear each working framebuffer before a pass draws into it. |
opt.clearDisplay optional |
boolean |
true |
If true and display is true, clear the main canvas before drawing the final output. |
opt.clearFn optional |
function |
How to clear a working framebuffer before a pass. Defaults to background(0). |
|
opt.clearDisplayFn optional |
function |
How to clear the main canvas before the final output. Defaults to clearFn. |
|
opt.draw optional |
function |
How to draw the current texture onto the current target. Defaults to a full-canvas copy. |
Returns p5.Framebuffer|null The framebuffer holding the final result, or null when no working framebuffers were available.