-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
docs(p5.strands): document smoothstep #8459
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
base: dev-2.0
Are you sure you want to change the base?
Conversation
|
🎉 Thanks for opening this pull request! For guidance on contributing, check out our contributor guidelines and other resources for contributors! Thank You! |
|
I’ve updated the
Both examples now follow the p5.strands patterns from the tutorial and should run as-is. I also ran Happy to iterate further if you have more suggestions |
|
Hi @jjnawaaz! (I only checked your first example.) I would recommend always developing, testing, and saving all examples on the p5 web editor first, finally pasting them into the reference comment only once you're happy that they run without error. If you do need to make later modifications to the example code, I would absolutely make the change back in the p5 web editor, rather than directly in the comment-block of the .js source file, so that you can again ensure your example code runs. The back-and-forth process can be a little laborious, I would agree - that's all the more reason to get your examples as close to perfect as possible before integrating them into the comment block. You can also include, in this conversation, links to your intended examples in the web editor while they're under discussion - that can make it a lot more convenient for you, and for reviewers, during early feedback. Let me know if I can help! |
|
Also, I could be wrong but I think the usefulness of smoothstep will be demonstrated better by a narrower transition region between the colours. If it's just being used to make a linear transition across essentially the entire width of the canvas, then we may as well just use the normalized x value directly, without smoothstep. I hope that makes sense! |
|
Hi @nbogie - thanks a lot for the detailed feedback, this is really helpful. You’re absolutely right: pixelInputs isn’t available in baseColorShader, which explains why the first example doesn’t run. I’ll revise that example to use only inputs that are valid for baseColorShader, and I’ll make sure to test it in the p5 Web Editor before updating the reference. Good point as well about the transition region - I agree that using smoothstep over the entire canvas doesn’t really demonstrate its purpose. I’ll tighten the transition window so the benefit of smoothstep (soft edges vs a linear ramp) is clearer. I’ll post an updated example shortly and, if helpful, include a link to the Web Editor sketch while it’s under discussion. |
|
I’ve pushed an update addressing the review comments: Replaced the earlier examples with tested, working p5.strands filter examples First example now demonstrates smoothstep using only screen coordinates (no uniforms), with a narrow transition band so its effect is clear Second example builds on that by introducing a uniform for animation Both examples were tested in the p5 Web Editor (2.x / p5.strands) and verified via npm run build:reference in the website repo |
|
Hi! That first example is working for me now - well done. |
|
Hi Thanks, and I’m glad the example is running now. |
|
I’ve updated the examples to further reduce the number of concepts introduced alongside smoothstep: The first example now shows a simple grayscale fade across the canvas using only smoothstep and a coordinate (no uniforms, no texture sampling). The second example builds on the first by introducing a single uniform to animate the transition. Both examples were tested in the p5 Web Editor using the p5.js 2.0 / p5.strands environment and should run as-is. Happy to iterate further if there’s an even simpler formulation you’d like to see. |
Resolves #8442
Changes
smoothstep()function in the p5.strands APIsmoothstepcombineColorsScreenshots of the change
Not applicable (documentation-only change).
PR Checklist
npm run lintpasses