Skip to content

Conversation

@davepagurek
Copy link
Contributor

Resolves #8343

Changes

  • The hardcoded use of gl_InstanceID, which is a WebGL-specific thing, has been replaced with a function in the p5.strands backend so that the GLSL and WGSL versions can return their own things.
  • Because in WGSL the instance ID is not a global, but something passed in optionally to fn main, there is now more automatic code rewriting in the vertex shader to support this:
    • @builtin(instance_index) instanceID: u32 is automatically added as a parameter to main
    • All hook functions are automatically given instanceID: u32 as an additional parameter
    • All hook function calls now pass the instanceID variable in after their other parameters

Screenshots of the change

We get multiple shapes now! https://editor.p5js.org/davepagurek/sketches/xa0XpbxAI

image

PR Checklist

@davepagurek davepagurek merged commit 0d8f347 into dev-2.0 Dec 19, 2025
5 checks passed
@davepagurek davepagurek deleted the fix/webgpu-instancing branch December 19, 2025 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants