Yeah you’re right. So basically the sketch runs as if the shader wasn’t applied (this shader doesn’t modify the current pixels array, but it actually draws over it, in this case a checkerboard pattern) and the result here is that it’s as if this image is transparent.
Oh I didn’t know that, I sometimes run into NullPointerExceptions when loadPixels() is called without beginDraw() before but I think that this is due to the fact there was actually nothing drawn onto the PGraphics beforehand.
This is also one of the things I tried before. This is why I tried recreating my issue on a simpler sketch :
PGraphics inBetween;
PGraphics shadedLayer;
PImage image;
void setup(){
size(1280, 720, P2D);
inBetween = createGraphics(1280, 720);
inBetween.beginDraw();
inBetween.background(255);
inBetween.endDraw();
shadedLayer = createGraphics(1280, 720, P2D);
image = loadImage("image.png");
}
void draw(){
shadeLayer();
method1();
//method2();
//method3();
//method4();
image(inBetween, 0, 0);
}
void method1(){
inBetween.beginDraw();
inBetween.image(shadedLayer, 0, 0);
inBetween.endDraw();
}
void method2(){
shadedLayer.loadPixels();
inBetween.loadPixels();
arrayCopy(shadedLayer.pixels, inBetween.pixels);
inBetween.updatePixels();
shadedLayer.updatePixels();
}
void method3(){
inBetween.beginDraw();
inBetween.image(shadedLayer.get(), 0, 0);
inBetween.endDraw();
}
void method4(){
shadedLayer.loadPixels();
inBetween.loadPixels();
for(int x = 0; x < shadedLayer.width; x++){
for(int y = 0; y < shadedLayer.height; y++){
inBetween.pixels[x + y * inBetween.width] = shadedLayer.pixels[x + y * shadedLayer.width];
}
}
inBetween.updatePixels();
shadedLayer.updatePixels();
}
void shadeLayer(){
shadedLayer.beginDraw();
shadedLayer.image(image, 0, 0);
shadedLayer.endDraw();
shadedLayer.filter(BLUR, 10);
}
But in this case all methods seem to work so… perhaps my issue isn’t even where I thought it was…
Thanks for your help @GoToLoop by the way.