-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[WIP] Docs: Add initial draft of Strands documentation (feedback wanted) #7940
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?
Changes from 1 commit
a3aeaa2
8e199d8
c9d07c1
06cf619
1d01ca8
e73b524
6b54ecd
1146190
36c4c2d
6e1311d
58d8e5d
483edcb
29fbe52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1642,31 +1642,20 @@ if (typeof p5 !== 'undefined') { | |
|
||
|
||
/* ------------------------------------------------------------- */ | ||
/** | ||
* @typedef {Object} Vertex | ||
* @property {{x: number, y: number, z: number}} position - The position of the vertex in world space. | ||
* @property {{x: number, y: number, z: number}} normal - The normal vector at the vertex in world space. | ||
* @property {{x: number, y: number}} texCoord - The texture coordinates (x, y) for the vertex. | ||
* @property {{r: number, g: number, b: number, a: number}} color - The color at the vertex. | ||
*/ | ||
|
||
/** | ||
* @function getWorldInputs | ||
* @experimental | ||
* @description | ||
* Registers a callback to modify the world-space properties of each vertex in a shader. This hook can be used inside {@link p5.baseMaterialShader}.modify() and similar shader modify calls to customize vertex positions, normals, texture coordinates, and colors before rendering. "World space" refers to the coordinate system of the 3D scene, before any camera or projection transformations are applied. | ||
* Registers a callback to modify the world-space properties of each vertex in a shader. This hook can be used inside <a href="#/p5/baseMaterialShader">baseMaterialShader()</a>.modify() and similar shader modify calls to customize vertex positions, normals, texture coordinates, and colors before rendering. "World space" refers to the coordinate system of the 3D scene, before any camera or projection transformations are applied. | ||
* | ||
* This hook is available in: | ||
* - {@link p5.baseMaterialShader} | ||
* - {@link p5.baseNormalShader} | ||
* - {@link p5.baseColorShader} | ||
* - {@link p5.baseStrokeShader} | ||
* - <a href="#/p5/baseMaterialShader">baseMaterialShader()</a> | ||
* - <a href="#/p5/baseNormalShader">baseNormalShader()</a> | ||
* - <a href="#/p5/baseColorShader">baseColorShader()</a> | ||
* - <a href="#/p5/baseStrokeShader">baseStrokeShader()</a> | ||
* | ||
* @param {function(Vertex): Vertex} callback | ||
* A callback function which receives and returns a Vertex struct. | ||
* | ||
* @see {@link p5.baseMaterialShader} | ||
* @see {@link p5.Shader#modify} | ||
* @param {function} callback | ||
* A callback function which receives a vertex object containing position (vec3), normal (vec3), texCoord (vec2), and color (vec4) properties. The function should return the modified vertex object. | ||
* | ||
* @example | ||
* <div modernizr='webgl'> | ||
|
@@ -1700,19 +1689,16 @@ if (typeof p5 !== 'undefined') { | |
* @function combineColors | ||
* @experimental | ||
* @description | ||
* Registers a callback to customize how color components are combined in the fragment shader. This hook can be used inside {@link p5.baseMaterialShader}.modify() and similar shader modify calls to control the final color output of a material. The callback receives a ColorComponents struct and should return an object with a `color` property ({ r, g, b }) and an `opacity` property (number). | ||
* Registers a callback to customize how color components are combined in the fragment shader. This hook can be used inside <a href="#/p5/baseMaterialShader">baseMaterialShader()</a>.modify() and similar shader modify calls to control the final color output of a material. The callback receives color components (baseColor, diffuse, ambientColor, ambient, specularColor, specular, emissive, opacity) and returns a vec4 for the final color. | ||
* | ||
* This hook is available in: | ||
* - {@link p5.baseMaterialShader} | ||
* - {@link p5.baseNormalShader} | ||
* - {@link p5.baseColorShader} | ||
* - {@link p5.baseStrokeShader} | ||
* | ||
* @param {function(ColorComponents): { color: {r: number, g: number, b: number}, opacity: number }} callback | ||
* A callback function which receives a ColorComponents struct and returns the final color and opacity. | ||
* - <a href="#/p5/baseMaterialShader">baseMaterialShader()</a> | ||
davepagurek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* - <a href="#/p5/baseNormalShader">baseNormalShader()</a> | ||
* - <a href="#/p5/baseColorShader">baseColorShader()</a> | ||
* - <a href="#/p5/baseStrokeShader">baseStrokeShader()</a> | ||
* | ||
* @see {@link p5.baseMaterialShader} | ||
* @see {@link p5.Shader#modify} | ||
* @param {function} callback | ||
* A callback function which receives color components (baseColor, diffuse, ambientColor, ambient, specularColor, specular, emissive, opacity) and returns a vec4 for the final color. | ||
* | ||
* @example | ||
* <div modernizr='webgl'> | ||
|
@@ -1723,21 +1709,20 @@ if (typeof p5 !== 'undefined') { | |
* myShader = baseMaterialShader().modify(() => { | ||
* combineColors(components => { | ||
* // Custom color combination: add a red tint | ||
* let color = { | ||
* r: components.baseColor.r * components.diffuse.r + | ||
* components.ambientColor.r * components.ambient.r + | ||
* components.specularColor.r * components.specular.r + | ||
* components.emissive.r + 0.2, | ||
* g: components.baseColor.g * components.diffuse.g + | ||
* components.ambientColor.g * components.ambient.g + | ||
* components.specularColor.g * components.specular.g + | ||
* components.emissive.g, | ||
* b: components.baseColor.b * components.diffuse.b + | ||
* components.ambientColor.b * components.ambient.b + | ||
* components.specularColor.b * components.specular.b + | ||
* components.emissive.b | ||
* }; | ||
* return { color, opacity: components.opacity }; | ||
* let r = components.baseColor.r * components.diffuse.r + | ||
* components.ambientColor.r * components.ambient.r + | ||
* components.specularColor.r * components.specular.r + | ||
* components.emissive.r + 0.2; | ||
* let g = components.baseColor.g * components.diffuse.g + | ||
* components.ambientColor.g * components.ambient.g + | ||
* components.specularColor.g * components.specular.g + | ||
* components.emissive.g; | ||
* let b = components.baseColor.b * components.diffuse.b + | ||
* components.ambientColor.b * components.ambient.b + | ||
* components.specularColor.b * components.specular.b + | ||
* components.emissive.b; | ||
* let a = components.opacity; | ||
* return vec4(r, g, b, a); | ||
* }); | ||
* }); | ||
* } | ||
|
@@ -1757,20 +1742,17 @@ if (typeof p5 !== 'undefined') { | |
* @function getPointSize | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a heads up -- currently the only public base shaders are: The point shader, while it has some hooks, is currently still private, as we may end up using the stroke shader to render points in the future. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@davepagurek Thank you for the clarification regarding public base shaders. I’ve updated the documentation for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@davepagurek Thank you for clarifying! I have removed the documentation for |
||
* @experimental | ||
* @description | ||
* Registers a callback to modify the size of points when rendering with a shader. This hook can be used inside {@link p5.baseMaterialShader}.modify() or similar, when drawing points (e.g., with the point() function in WEBGL mode). The callback receives the current point size (number) and should return the new size (number). | ||
* Registers a callback to modify the size of points when rendering with a shader. This hook can be used inside <a href="#/p5/baseMaterialShader">baseMaterialShader()</a>.modify() or similar, when drawing points (e.g., with the point() function in WEBGL mode). The callback receives the current point size (number) and should return the new size (number). | ||
* | ||
* This hook is available in: | ||
* - {@link p5.baseMaterialShader} | ||
* - {@link p5.baseNormalShader} | ||
* - {@link p5.baseColorShader} | ||
* - {@link p5.baseStrokeShader} | ||
* - <a href="#/p5/baseMaterialShader">baseMaterialShader()</a> | ||
* - <a href="#/p5/baseNormalShader">baseNormalShader()</a> | ||
* - <a href="#/p5/baseColorShader">baseColorShader()</a> | ||
* - <a href="#/p5/baseStrokeShader">baseStrokeShader()</a> | ||
* | ||
* @param {function(size: number): number} callback | ||
* @param {function} callback | ||
* A callback function which receives and returns the point size. | ||
* | ||
* @see {@link p5.baseMaterialShader} | ||
* @see {@link p5.Shader#modify} | ||
* | ||
* @example | ||
* <div modernizr='webgl'> | ||
* <code> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we describe the input as being an object with the properties
baseColor
,diffuse
,ambientColor
, etc? I think it would be important to describe the size of each item (e.g. position/normal are vec3s, texture coordinates are vec2s, color is a vec4) -- although maybe rather than using terms likevec3
we could describe it as "a vector with three components" to avoid referencing thevec3
type, since there aren't user-facing docs for that yet. A bullet list might work if that's too much info to put in one sentence.One other note is that when we refer to a name of a property/variable/etc in code, such as when listing properties here, we should put the names in backticks so they render as code (
baseColor
instead of baseColor.)Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davepagurek Thank you for your feedback! I’ve updated the documentation for
combineColors
to describe the input as an object with each property listed in a bullet list, using backticks for property names and describing the size of each in plain language. The example now uses array notation for vector properties. Please let me know if you’d like any further adjustments.