Skip to content

Add 3D noise(vec3) support to p5.strands #7978

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

@LalitNarayanYadav LalitNarayanYadav commented Jul 19, 2025

Summary

This PR adds noise(x, y, z) support to p5.strands using a GLSL-based 3D noise implementation.


Changes Included

  • New GLSL File: noise3DGLSL.glsl

    • Implements fractal noise in 3D using vec3 input.
    • Based on public domain / MIT-licensed noise code.
  • Updated: ShaderGenerator.js

    • fn.noise now supports noise(x, y, z) in shader context via vec3.
    • Graceful fallback to default p5.js noise when not in shader mode.
    • Handles both 2D and 3D noise internally.

Usage Example

modify(() => {
  let n = noise(x, y, time); // 3D noise support
  stroke(n);
});

PR Checklist

  • npm run lint passes
  • [Inline reference] is included / updated
  • [Unit tests] are included / updated

[Inline reference]: https://p5js.org/contribute/contributing_to_the p5js_reference/
[Unit tests]: https://github.com/processing/p5.js/tree/main/contributor_docs#unit-tests

@LalitNarayanYadav
Copy link
Contributor Author

fixes #7897

@LalitNarayanYadav
Copy link
Contributor Author

Hi @davepagurek! I've opened a PR that adds noise(vec3) support in p5.strands using a 3D GLSL noise implementation. It falls back gracefully to the original noise() outside shader mode and includes both 2D and 3D support within the same function. Let me know if you'd like any refinements or if there's a preferred way to handle noiseDetail() in the future .

@lukeplowden
Copy link
Member

Thank you Lalit, great work! I will review this later on today.

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