Closed Skuzee closed 1 month ago
I was able to get it partially working. I changed my apply definition to use filter() instead of shader() and it works correctly if I compose directly to the main sketch window. However, composing to a PGraphics canvas, then displaying that with image(), I get the same black halo.
I'm starting to think it might actually be a PGraphics issue and have something to do with PGraphics' default state being non-transparent black. (i.e. using clear())
Even with avoiding clear() and trying to force the canvas background to transparent, or to white I haven't seen any improvement. Below is my updated apply() and draw():
@Override
public void apply(Supervisor supervisor) {
PGraphics pass = supervisor.getNextPass();
supervisor.clearPass(pass);
pass.beginDraw();
pass.background(255);
pass.image(supervisor.getCurrentPass(), 0, 0);
pass.endDraw();
pass.filter(shader);
}
void draw() {
background(200, 200, 255, 255); // light blue
canvas.beginDraw();
canvas.background(255, 200, 200, 255); // pink
canvas.endDraw();
fx.render(canvas);
// fx.compose(canvas); oops ignore this.
fx.pass(shCircleMask);
fx.compose(); // compose to screen works
fx.compose(canvas); // composing to a canvas, then displaying it does not.
image(canvas, width/2, height/2,width/2, height/2);
}
I think I found my problem.
from http://processing.github.io/processing-javadocs/core/ under createGraphics
the main drawing surface which is completely opaque, surfaces created with createGraphics() can have transparency. This makes it possible to draw into a graphics and maintain the alpha channel. By using save() to write a PNG or TGA file, the transparency of the graphics object will be honored. Note that transparency levels are binary: pixels are either complete opaque or transparent. For the time being, this means that text characters will be opaque blocks. This will be fixed in a future release (Issue 80). ( end auto-generated )
I guess this mean I can't do gradual transparencies with PGraphics. It's strange that the main window will still respect the alpha channel of the colors when blending, but it seems like drawing to a graphic does not maintain the alpha of the pixel color data? (from what I see so far.) Perhaps I can set it directly.
I seem to have found my answer, although it's not exactly a solution! 😠😓 Have a great day!
Hello! Sorry if this is something I'm doing wrong. I see this is somewhat of an older library.
I am trying to use this library to configure and run my own shaders. When I apply my shaders with the usual filter(myShader), the transparency and color blending look correct. When I use the PostFXSupervisor and use fx.pass(myShaderObject); then compose it, the blending of the edges of my smoothstep are colored black/gray. I know this might be a big ask, but any insight you can lend me would be amazing! I can't tell if I'm using the library wrong. 💛
results with library
expected results
my pde sketch:
my shader class:
This is my shader. It just uses a smoothstep as an SDF to fade the original texture's aplha to 0 (transparent)