-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Add WIP WebGPU mode #8179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev-2.0
Are you sure you want to change the base?
Add WIP WebGPU mode #8179
Conversation
|
Actually I'll have to give this a tad more thought, since it needs more than just the webgpu renderer -- it also needs basically everything else included in the webgl export other than its renderer, e.g. Lines 19 to 37 in aa73cea
If I make a similar function for WebGPU that sets up all of those, it'd probably work but would double-add those addons if both WebGPU and WebGL are added I think? Do you think that's OK or should we add some way to detect when an addon function has already been called? It'd have to pay attention to what's passed in because p5.Graphics would possibly also need to call the same function but with different parameters. |
|
It would be nice if the call to The main thing I'm currently thinking may be a problem is the decoration feature which if the same addon is registered multiple times then it will also create duplicate decoration. The other thing is that since the addon function will be called multiple times, would it affect some of the internal initialization of the addon if that is the case? Calling |
|
@limzykenneth I made an update to make |
|
Update: added a WGSL backend for p5.strands! This silly little demo is running this shader: baseMaterialShader().modify(() => {
const time = uniformFloat(() => millis())
p.getWorldInputs((inputs) => {
inputs.position.y += 40 * sin(time * 0.005);
return inputs;
});
})Screen.Recording.2025-11-22.at.7.29.16.PM.mov |
This refactors
RendererGLinto two classes,Renderer3D, and a subclassRendererGL. It also introduces a newRendererWebGPUthat extendsRenderer3Das well.No WebGPU code is bound by default. Currently it can be tested just by importing its addon module and setting it up, e.g. this test sketch using textures and framebuffers:
WebGPU test sketch source code
Notes
WEBGPUmode, you need toawait createCanvas(w, h, WEBGPU)await loadPixels()andawait get()imageLight()font rendering