Skip to content

Commit ff24b96

Browse files
authored
Merge pull request #8546 from processing/fix/webgpu-filter-shader
Fix WebGPU filter shader parameters being named differently than in WebGL
2 parents 8196270 + 053d350 commit ff24b96

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

src/webgpu/p5.RendererWebGPU.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3124,7 +3124,7 @@ ${hookUniformFields}}
31243124
{
31253125
vertex: {},
31263126
fragment: {
3127-
"vec4<f32> getColor": `(inputs: FilterInputs, tex: texture_2d<f32>, tex_sampler: sampler) -> vec4<f32> {
3127+
"vec4<f32> getColor": `(inputs: FilterInputs, canvasContent: texture_2d<f32>, canvasContent_sampler: sampler) -> vec4<f32> {
31283128
return textureSample(tex, tex_sampler, inputs.texCoord);
31293129
}`,
31303130
},

test/unit/visual/cases/webgpu.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,26 @@ visualSuite("WebGPU", function () {
252252

253253
await screenshot();
254254
});
255+
256+
visualTest('filter shaders with flat API', async function(p5, screenshot) {
257+
await p5.createCanvas(50, 50, p5.WEBGPU);
258+
p5.background(255);
259+
p5.noStroke();
260+
p5.fill(0);
261+
p5.circle(0, 0, 20);
262+
const invert = p5.buildFilterShader(({ p5 }) => {
263+
p5.filterColor.begin();
264+
const regular = p5.getTexture(
265+
p5.filterColor.canvasContent,
266+
p5.filterColor.texCoord
267+
);
268+
const inverted = [1 - regular.rgb, regular.a];
269+
p5.filterColor.set(inverted);
270+
p5.filterColor.end();
271+
}, { p5 });
272+
p5.filter(invert);
273+
await screenshot();
274+
});
255275
});
256276

257277
visualSuite('filters', function() {
356 Bytes
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"numScreenshots": 1
3+
}

0 commit comments

Comments
 (0)