Using filter() inside of a PGraphics canvas?

Learning about using the PGraphics to crate and edit images and graphics before drawing them. Or, in this case, in order to be sent out via Syphon. Syphon is essentially an invisible video cable between different apps on Mac OSX. Spout is the Windows version.

Everything was working great until I started trying to use filter() within the PGrahics canvas.

The peculiar thing is that the filters used, INVERT & BLUR, do show in the Processing window but not in the Syphon output.

Is there any reason for this and/or a fix?

Should the filters be applied in a different way to ensure they are included in the Syphon output?

See attached screenshot and code below.

Find the library and the “Simple Client” app on the GitHub here.

import codeanticode.syphon.*;

PGraphics canvas;
SyphonServer server;

void setup() { 
  size(400,400, P3D);
  canvas = createGraphics(400, 400, P3D);
  frameRate(30);
  
  // Create syhpon server to send frames out.
  server = new SyphonServer(this, "Processing Syphon");
}

void draw() {
  canvas.beginDraw();
  canvas.background(127);
  canvas.lights();
  canvas.translate(width/2, height/2);
  canvas.rotateX(frameCount * 0.01);
  canvas.rotateY(frameCount * 0.01);  
  canvas.box(150);
  canvas.filter(INVERT);
  canvas.filter(BLUR, 3);
  canvas.endDraw();
  image(canvas, 0, 0);
  server.sendImage(canvas);
}

Hi,

i tried your code, and it works well on my computer

so i can’t help much, may be it s about when the filters are really applied
( i assumed it was at endDraw but may be at the end of draw() loop)
so i will try an canvas.updatePixels(); before server.sendImage(canvas);

Well that is strange thank you for the update though!

I notice in your console there are no red errors. I do have them.

It is usually caused by not having the frameRate() function in there.

Perhaps there is a difference between machines enough to cause this?

MacBook Pro Mid 2015
OS 11.5.1
Processing 3.5.4
Syphon v 3.0

hi,
yes i had those same red errors on my macbook 2013, i recently switched to a m1 and i don t have them anymore
M1
Processing 3.5.4
syphon … i don 't know, i use current “simple client” app
anyhow it 's quite unlikely problem is on syphon side
i will try to put server.sendImage(canvas); just after draw()
so you sent the previous frame “canvas” image, after it was rendered, i think problem is about when do filter() and image(,) are really applied

void draw() {
 server.sendImage(canvas);
  canvas.beginDraw();
 ...
}