Skip to content

Conversation

hxrshxz
Copy link
Contributor

@hxrshxz hxrshxz commented Oct 18, 2025

Resolves #8160

Changes

Added support for noiseDetail() in p5.strands shaders:

  1. src/math/noise.js: Added two private getter functions

    • _getNoiseOctaves() - Returns current octaves value
    • _getNoiseAmpFalloff() - Returns current falloff value
  2. src/webgl/p5.RendererGL.js: Added noise uniforms to all default shaders

    • uNoiseOctaves (int) and uNoiseAmpFalloff (float) uniforms
    • Applied to: baseMaterialShader, baseNormalShader, baseColorShader, pointShader, lineShader

How It Works

When noiseDetail() is called, the values are now automatically passed to shaders as uniforms. This allows p5.strands to implement GLSL noise functions that use the current noise detail settings instead of hardcoded values.

PR Checklist

  • npm run lint passes
  • No breaking changes to existing code
  • Follows existing code patterns (no unit tests added per historical precedent)

@Copilot Copilot AI review requested due to automatic review settings October 18, 2025 15:47
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds WebGL shader support for p5.js noise parameters by exposing the current noise detail settings (octaves and amplitude falloff) to shaders as uniforms. This enables p5.strands to implement GLSL noise functions that respect the current noiseDetail() settings.

  • Added two private getter functions to expose noise octaves and amplitude falloff values
  • Updated all default WebGL shaders to include noise parameter uniforms

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/math/noise.js Added private getter functions to expose current noise octaves and amplitude falloff values
src/webgl/p5.RendererGL.js Added noise uniforms to all default shaders (base material, normal, color, point, and line shaders)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@davepagurek
Copy link
Contributor

Hi! This doesn't quite do what the original issue was asking for. The original issue is for p5.strands -- a feature of p5.js 2.0, which is on the dev-2.0 branch, not the main branch. Here's a test sketch that uses p5.strands noise: https://editor.p5js.org/davepagurek/sketches/XfK5LNYPK What we want to do is be able to write noiseDetail(...) before the noise call in the shader and have it work. You'll want to create a similar sort of test sketch to verify your solution.

I linked in the original issue to some spots in the code where this modification will have to take place, but the main part is that we'll need to pass the current values in when the user calls noise() within a p5.strands shader, which happens here:

if (args.length === 3) {
nodeArgs = [fn.vec3(args[0], args[1], args[2])];
} else if (args.length === 2) {
nodeArgs = [fn.vec3(args[0], args[1], 0)];
} else {
nodeArgs = args;
}
const { id, dimension } = build.functionCallNode(strandsContext, 'noise', nodeArgs, {
overloads: [{
params: [DataType.float3],
returnType: DataType.float1,
}]
});

@hxrshxz hxrshxz closed this Oct 18, 2025
@hxrshxz
Copy link
Contributor Author

hxrshxz commented Oct 18, 2025

Thank you for clarifying @davepagurek I have closed this one and opened a new one #8163

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.

Support noiseDetail in p5.strands

2 participants