Description
Increasing access
In 2.0, we released p5.strands! Currently, the documentation is a little sparse, and you have to find either our one tutorial, or look at the examples on a base shader (e.g. baseMaterialShader.) The text of the referencedoesn't mention strands. If we can document p5.strands more like how we document regular p5 functions, more people can discover it, and learning how to use it will be more straightforward.
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 p5.strands snippet might look something like this:
myShader = baseMaterialShader().modify(() => {
let time = uniformFloat(() => millis());
getWorldInputs((inputs) => {
inputs.position.y +=
20 * sin(time * 0.001 + inputs.position.x * 0.05);
return inputs;
});
});
The getWorldInputs
function is a hook. These hooks are currently only described on the reference for the base shaders that use them (e.g. https://beta.p5js.org/reference/p5/basematerialshader/), and are currently described in GLSL, as that was the only way to modify shaders at the time those docs were written.
I'm proposing that we:
- Create a new reference page for each hook function (e.g.
getObjectInputs
,combineColors
, etc)- Since these methods are dynamically created, the reference pages can be made by placing a doc comment block at the end of a file describing each method even though the method itself is not next to the comment block (similar to how properties of classes are documented.)
- Put these in a new p5.strands section or subsection of the reference by using
@module
(for section) and@submodule
(for subsection) in the doc comments. Open to ideas about exactly where in the reference it should go! - Describe without GLSL how to use the hook
- Create (or copy from the base shader) an example or two for each hook reference (e.g. for hooks coming from multiple shaders, maybe show an example of each?)
- Link back to all the base shader references that include it (e.g.
getObjectInputs
is on I think all of our base shaders)
- Update the base shader docs to link to all the individual hook docs rather than describing them all in a table
- Update the
shader.modify()
docs to mention p5.strands JS callbacks as well as the object-with-glsl option currently described
We don't have to do all of these in one go, I can make a subtasks for each if someone is interested in getting started on just a part of this 🙂