-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
I have an alpha mask that I'm using on the canvas. It works fine in the processing image, but when viewing the syphon feed, I only see the base layer. The mask and anything after are not rendered.
import processing.video.*;
import codeanticode.syphon.*;
PGraphics canvas;
SyphonServer server;
PImage mask;
PImage lines;
PImage backdrop;
Movie background;
void setup() {
size(1920,1080, P3D);
canvas = createGraphics(1920, 1080, P3D);
mask = loadImage("alpha_mask.png");
backdrop = loadImage("white_backdrop.png");
background = new Movie(this, "finalimage_1.mov");
background.loop();
// Create syhpon server to send frames out.
server = new SyphonServer(this, "Processing Syphon");
}
void draw() {
canvas.beginDraw();
canvas.background(100);
canvas.image(background, 420, 0);
canvas.mask(mask);
canvas.image(backdrop, 0, 0);
canvas.endDraw();
image(canvas, 0, 0);
server.sendImage(canvas);
}
void movieEvent(Movie m) {
m.read();
}
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
vade commentedon Sep 22, 2017
Ensure both apps agree on premultiplied vs unpremultiplied alpha. No idea what Processing's mask option does but my guess is your alpha is not premultiplied in Processing.
vade commentedon Sep 22, 2017
bangnoise commentedon Oct 25, 2017
I thought this sounded like it might be a real issue, but I can't get canvas.mask() to have any effect within Processing. If you can attach a minimal sketch folder with images to demonstrate the problem, I'll take a look.
codeanticode commentedon Mar 12, 2022
Revising very old issues, just for fun :-)
In this case, what's happening is that the texture that's backing the rendering surface (either onscreen or offscreen) is not updated with the output from the filter (mask() in P2D/P3D internally calls filter()), for some reason (it should, so opened a bug about this in the main processing4 repo: processing/processing4#449).
But, it gets full updated in the next frame, so one temporary workaround is to move the server.sendImage(canvas) call to the top of the draw() function.
A shorter example demonstrating the workaround. Original code (filter output does not show up in the receiveFrames sketch)
Modified code (it works as expected):
Also worth noting that the issue affects both the filter() function that takes only predetermined filters and the one with the PShader argument.