Hey Amnon, thanks for the reply.
I tried clear() without any success, so I followed up to make a standalone code to demonstrate my problem and to my surprise I could not replicate the problem. So after a few hours bashing my head on 'why', I ended up tracing the root of the problem to OpenGL retained mode (PShape). Here is a sample code:
PGraphics textLayer;
PGraphics bgLayer;
PShape shapeTest;
PFont font;
void setup() {
size(800, 800, P3D);
textLayer = createGraphics(width, height, P3D);
bgLayer = createGraphics(width, height, P3D);
String[] fontList = PFont.list();
font = createFont(fontList[round(random(fontList.length-1))], 200, true);
textLayer.beginDraw();
textLayer.fill(255);
textLayer.noStroke();
textLayer.textFont(font);
textLayer.textAlign(CENTER, CENTER);
textLayer.text("TESTE", width/2, height/2);
textLayer.endDraw();
shapeTest = createShape();
shapeTest.beginShape();
shapeTest.noStroke();
shapeTest.noFill();
shapeTest.textureMode(NORMAL);
shapeTest.texture(textLayer);
shapeTest.vertex(-width/2, -height/2, 0,0);
shapeTest.vertex(width/2, -height/2, 1,0);
shapeTest.vertex(width/2, height/2, 1,1);
shapeTest.vertex(-width/2, height/2, 0,1);
shapeTest.endShape(CLOSE);
bgLayer.beginDraw();
//Black outline
bgLayer.background(0, 0);
//Black outline the same
//bgLayer.clear();
//Red outline
//bgLayer.background(255, 255, 255, 0);
bgLayer.translate(width/2, height/2);
bgLayer.shape(shapeTest);
bgLayer.endDraw();
}
void draw() {
background(125);
image(bgLayer, 0, 0);
}