Skip to content

Enhance p5.strands noise() to support noise(x, y) and 4-octave fractal noise #7964

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
wants to merge 2 commits into
base: dev-2.0
Choose a base branch
from

Conversation

LalitNarayanYadav
Copy link
Contributor

Summary

This PR improves the noise() function in p5.strands by aligning it more closely with core p5.js functionality and improving its visual quality through fractal noise.


What's Included

  • noise(x, y) is now supported in addition to noise([x, y])
  • Added 4-octave fractal noise implementation in GLSL
  • noiseGLSL.glsl injected into both vertex and fragment stages
  • Falls back to the original p5.js noise() function outside of strands
  • MIT license attribution added for the noise basis function

Technical Notes

  • The fn.noise() wrapper checks for 2 arguments and wraps them using vec2(...) to allow for noise(x, y) syntax.
  • The GLSL file noiseGLSL.glsl defines baseNoise() and a new noise() function using a fixed 4-octave loop:
    for (int i = 0; i < 4; i++) {
      result += amplitude * baseNoise(st * frequency);
      frequency *= 2.0;
      amplitude *= 0.5;
    }
    
    

PR Checklist

@LalitNarayanYadav
Copy link
Contributor Author

fixes #7897

@LalitNarayanYadav
Copy link
Contributor Author

Hi @davepagurek! I’ve pushed the updated changes:

  • noise(x, y) is now supported alongside noise(vec2)
  • The GLSL noise function now uses 4 octaves for smoother fractal noise
  • Declarations are added to both vertex and fragment stages
  • Falls back to original p5.js noise outside of strands

Let me know if anything needs adjustment.

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.

1 participant