Hi, everyone, and thanks in advance for any help.
In order to achieve this, I’m trying actually to apply the PShader to a PGraphics object, and then pass this PGraphics as an argument for the background.
When I use the resultant PGraphics in an image() function, it works perfectly, but nothing is shown when I use it for the background().
If I draw anything inside the PGraphics (for example a rect), then that is shown in the background, but not the PShader I need;
Has anyone faced this problem and got a solution? Thanks a lot.
I paste the Processing code below
PShader shader;
float wE, hE;
PGraphics backImgPG;
void setup() {
size(1024, 768, P3D);
background(0);
shader=loadShader("../frag/72.frag");
shader.set("u_resolution", float(width), float(height));
backImgPG=createGraphics(width, height);
rectMode(CENTER);
noStroke();
}
void draw() {
shader.set("u_time", millis() / 1000.0);
shader(shader);
//image(shaderPG(backImgPG), 0, 0);//works
background(shaderPG(backImgPG));//doesn't work
}
PGraphics shaderPG(PGraphics _pg) {
_pg.beginDraw();
_pg.endDraw();
return backImgPG;
}