diff --git a/src/webgpu/p5.RendererWebGPU.js b/src/webgpu/p5.RendererWebGPU.js index 312d2e931b..678745f6fb 100644 --- a/src/webgpu/p5.RendererWebGPU.js +++ b/src/webgpu/p5.RendererWebGPU.js @@ -3124,7 +3124,7 @@ ${hookUniformFields}} { vertex: {}, fragment: { - "vec4 getColor": `(inputs: FilterInputs, tex: texture_2d, tex_sampler: sampler) -> vec4 { + "vec4 getColor": `(inputs: FilterInputs, canvasContent: texture_2d, canvasContent_sampler: sampler) -> vec4 { return textureSample(tex, tex_sampler, inputs.texCoord); }`, }, diff --git a/test/unit/visual/cases/webgpu.js b/test/unit/visual/cases/webgpu.js index e16c2eb358..9dbc344dea 100644 --- a/test/unit/visual/cases/webgpu.js +++ b/test/unit/visual/cases/webgpu.js @@ -252,6 +252,26 @@ visualSuite("WebGPU", function () { await screenshot(); }); + + visualTest('filter shaders with flat API', async function(p5, screenshot) { + await p5.createCanvas(50, 50, p5.WEBGPU); + p5.background(255); + p5.noStroke(); + p5.fill(0); + p5.circle(0, 0, 20); + const invert = p5.buildFilterShader(({ p5 }) => { + p5.filterColor.begin(); + const regular = p5.getTexture( + p5.filterColor.canvasContent, + p5.filterColor.texCoord + ); + const inverted = [1 - regular.rgb, regular.a]; + p5.filterColor.set(inverted); + p5.filterColor.end(); + }, { p5 }); + p5.filter(invert); + await screenshot(); + }); }); visualSuite('filters', function() { diff --git a/test/unit/visual/screenshots/WebGPU/Shaders/filter shaders with flat API/000.png b/test/unit/visual/screenshots/WebGPU/Shaders/filter shaders with flat API/000.png new file mode 100644 index 0000000000..28c41ce592 Binary files /dev/null and b/test/unit/visual/screenshots/WebGPU/Shaders/filter shaders with flat API/000.png differ diff --git a/test/unit/visual/screenshots/WebGPU/Shaders/filter shaders with flat API/metadata.json b/test/unit/visual/screenshots/WebGPU/Shaders/filter shaders with flat API/metadata.json new file mode 100644 index 0000000000..2d4bfe30da --- /dev/null +++ b/test/unit/visual/screenshots/WebGPU/Shaders/filter shaders with flat API/metadata.json @@ -0,0 +1,3 @@ +{ + "numScreenshots": 1 +} \ No newline at end of file