diff --git a/src/webgl/material.js b/src/webgl/material.js index 3fdb3733cd..28d6174a79 100644 --- a/src/webgl/material.js +++ b/src/webgl/material.js @@ -3683,9 +3683,7 @@ function material(p5, fn){ ); break; } - if (!this._isErasing) { - this._cachedBlendMode = this.states.curBlendMode; - } + this._cachedBlendMode = this.states.curBlendMode; }; RendererGL.prototype.shader = function(s) { diff --git a/test/unit/visual/cases/webgl.js b/test/unit/visual/cases/webgl.js index e503f80981..14d354d500 100644 --- a/test/unit/visual/cases/webgl.js +++ b/test/unit/visual/cases/webgl.js @@ -533,4 +533,33 @@ visualSuite('WebGL', function() { screenshot(); }); }); + + visualSuite('erase()', () => { + visualTest('on the main canvas', (p5, screenshot) => { + p5.createCanvas(50, 50, p5.WEBGL); + p5.background(0); + p5.fill('red'); + p5.rect(-20, -20, 40, 40); + p5.erase(); + p5.circle(0, 0, 10); + p5.noErase(); + screenshot(); + }); + + visualTest('on a framebuffer', (p5, screenshot) => { + p5.createCanvas(50, 50, p5.WEBGL); + p5.background(0); + const fbo = p5.createFramebuffer(); + fbo.begin(); + p5.fill('red'); + p5.rect(-20, -20, 40, 40); + p5.erase(); + p5.circle(0, 0, 10); + p5.noErase(); + fbo.end(); + p5.imageMode(p5.CENTER); + p5.image(fbo, 0, 0); + screenshot(); + }); + }); }); diff --git a/test/unit/visual/screenshots/WebGL/erase()/on a framebuffer/000.png b/test/unit/visual/screenshots/WebGL/erase()/on a framebuffer/000.png new file mode 100644 index 0000000000..39c1f82597 Binary files /dev/null and b/test/unit/visual/screenshots/WebGL/erase()/on a framebuffer/000.png differ diff --git a/test/unit/visual/screenshots/WebGL/erase()/on a framebuffer/metadata.json b/test/unit/visual/screenshots/WebGL/erase()/on a framebuffer/metadata.json new file mode 100644 index 0000000000..2d4bfe30da --- /dev/null +++ b/test/unit/visual/screenshots/WebGL/erase()/on a framebuffer/metadata.json @@ -0,0 +1,3 @@ +{ + "numScreenshots": 1 +} \ No newline at end of file diff --git a/test/unit/visual/screenshots/WebGL/erase()/on the main canvas/000.png b/test/unit/visual/screenshots/WebGL/erase()/on the main canvas/000.png new file mode 100644 index 0000000000..464ffec3a4 Binary files /dev/null and b/test/unit/visual/screenshots/WebGL/erase()/on the main canvas/000.png differ diff --git a/test/unit/visual/screenshots/WebGL/erase()/on the main canvas/metadata.json b/test/unit/visual/screenshots/WebGL/erase()/on the main canvas/metadata.json new file mode 100644 index 0000000000..2d4bfe30da --- /dev/null +++ b/test/unit/visual/screenshots/WebGL/erase()/on the main canvas/metadata.json @@ -0,0 +1,3 @@ +{ + "numScreenshots": 1 +} \ No newline at end of file