Skip to content

Commit db08f6d

Browse files
JUNAID NAWAZJUNAID NAWAZ
authored andcommitted
docs(p5.strands): add smoothstep documentation
1 parent 626996e commit db08f6d

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

src/strands/p5.strands.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,45 @@ if (typeof p5 !== "undefined") {
275275
* </div>
276276
*/
277277

278+
/**
279+
* @method smoothstep
280+
* @description
281+
* A shader function that performs smooth Hermite interpolation between `0.0`
282+
* and `1.0`.
283+
*
284+
* This function is equivalent to the GLSL built-in
285+
* `smoothstep(edge0, edge1, x)` and is available inside p5.strands shader
286+
* callbacks. It is commonly used to create soft transitions, smooth edges,
287+
* fades, and anti-aliased effects.
288+
*
289+
* - Returns `0.0` when `x` is less than or equal to `edge0`
290+
* - Returns `1.0` when `x` is greater than or equal to `edge1`
291+
* - Smoothly interpolates between `0.0` and `1.0` when `x` is between them
292+
*
293+
* @param {Number} edge0
294+
* Lower edge of the transition
295+
* @param {Number} edge1
296+
* Upper edge of the transition
297+
* @param {Number} x
298+
* Input value to interpolate
299+
*
300+
* @returns {Number}
301+
* A value between `0.0` and `1.0`
302+
*
303+
* @example
304+
* <div modernizr='webgl'>
305+
* <code>
306+
* function material() {
307+
* let t = uniformFloat();
308+
* combineColors.begin();
309+
* let fade = smoothstep(0.2, 0.8, sin(t * 0.001));
310+
* combineColors.opacity *= fade;
311+
* combineColors.end();
312+
* }
313+
* </code>
314+
* </div>
315+
*/
316+
278317
/**
279318
* @method beforeVertex
280319
* @private

0 commit comments

Comments
 (0)