p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

[p5.strands] Support p5 global properties in p5.strands

Open davepagurek opened this issue 2 months ago • 6 comments

Increasing access

Currently, to use something like width or mouseX in a p5.strands shader, users will need to manually create a uniform and use that, e.g.:

const myMouseX = uniformFloat(() => mouseX)

This is different for how you'd use those properties in the rest of p5 and introduces a number of new concepts to do so, so it would smooth usage out a lot of we could remove that need.

Most appropriate sub-area of p5.js?

  • [ ] Accessibility
  • [ ] Color
  • [ ] Core/Environment/Rendering
  • [ ] Data
  • [ ] DOM
  • [ ] Events
  • [ ] Image
  • [ ] IO
  • [ ] Math
  • [ ] Typography
  • [ ] Utilities
  • [x] WebGL
  • [ ] Build process
  • [ ] Unit testing
  • [ ] Internationalization
  • [ ] Friendly errors
  • [ ] Other (specify if possible)

Feature enhancement details

Similar to how, while p5.strands is active, we replace the implementation of functions like noise to use a p5.strands version, while p5.strands is active, we could also replace the usage of properties like width and mouseX to be special strands nodes instead of just values. For each of these, when we detect it's being used, we can add it to a list of uniforms and give it a callback returning the global value, and return a strands node referencing that uniform. Then, users could just use those values directly in their shaders without needing to create uniforms themselves.

davepagurek avatar Oct 20 '25 21:10 davepagurek

@davepagurek I would like to work on this. Please assign it to me. Thanks

avinxshKD avatar Oct 24 '25 11:10 avinxshKD

Thanks @avinxshKD!

davepagurek avatar Oct 24 '25 12:10 davepagurek

Hi @davepagurek IF this issue still opens i would like to work on it please assign it to me

ayushman1210 avatar Nov 18 '25 06:11 ayushman1210

Hi! I believe @avinxshKD is still working on this one.

davepagurek avatar Nov 18 '25 11:11 davepagurek

Yes @davepagurek gimme some time I'll work on it and change as u wanted Some work came up

avinxshKD avatar Nov 18 '25 14:11 avinxshKD

no problem @avinxshKD! I took a few weeks to respond to your initial PR anyway 😅 feel free to take your time

davepagurek avatar Nov 18 '25 14:11 davepagurek