Skip to content

[p5.strands] Implementing a noise function in strands #7897

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

Open
1 of 17 tasks
lukeplowden opened this issue Jun 10, 2025 · 3 comments
Open
1 of 17 tasks

[p5.strands] Implementing a noise function in strands #7897

lukeplowden opened this issue Jun 10, 2025 · 3 comments

Comments

@lukeplowden
Copy link
Member

Increasing access

This enhancement is part of the effort to integrate p5.strands more integrated into the core library (see parent issue #7849)

Most appropriate sub-area of p5.js?

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

Feature enhancement details

A noise implementation in p5.strands would allow for a lot of interesting effects using p5.strands, for animating objects and rendering materials. This could be a GLSL implementation of simplex noise, or another algorithm.

In order to get this working, something similar to getTexture could be a good approach. That function is defined here in strands and also here in GLSL. This would mean making a new function call node in strands, and writing the GLSL function somewhere to be included in shaders. I would be inclined to make this a new GLSL file, since we might add more functions to it in the future.

The implementation can be different than the core library version of noise, with potential to add a noiseMode(GPU || CPU) in the future.

@davepagurek
Copy link
Contributor

Some notes for working on this:

  • Some noise approaches use a big table of noise values, but we probably don't want to use that for now if we're going to be adding this helper function to all shaders
    • Potentially in the future, we can conditionally add it only if a shader makes use of it, but if our implementation is small, it's OK not doing that yet
  • If we're borrowing a GLSL noise implementation from the internet, that could be OK but we should be explicit about it and discuss what its software license is
  • A lot of references to noise functions that you see only implement base noise. p5's noise() uses fractal noise, which looks something like this:
    for (int i = 0; i < 3; i++) {
      result += pow(2.0, -float(i)) * baseNoise(input * pow(2.0, float(i)));
    }
    In p5 the factors are controlled by noiseDetail, but it's also OK to just hardcode the default values for now and connect it to noiseDetail in a later update.

@ksen0 ksen0 moved this to Open for Discussion in p5.js 2.x 🌱🌳 Jun 10, 2025
@ksen0 ksen0 moved this from Open for Discussion to Ready for Work in p5.js 2.x 🌱🌳 Jun 10, 2025
@LalitNarayanYadav
Copy link
Contributor

Hi @davepagurek! Just leaving a comment here so you can assign the issue to me. Looking forward to working on this one too 🙂

@davepagurek
Copy link
Contributor

Thanks! I'll assign it to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Ready for Work
Development

No branches or pull requests

3 participants