You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @property {{x: number, y: number, z: number}} position - The position of the vertex in world space.
4
+
* @property {{x: number, y: number, z: number}} normal - The normal vector at the vertex in world space.
5
+
* @property {{x: number, y: number}} texCoord - The texture coordinates (x, y) for the vertex.
6
+
* @property {{r: number, g: number, b: number, a: number}} color - The color at the vertex.
7
+
*/
8
+
9
+
/**
10
+
* @function getWorldInputs
11
+
* @experimental
12
+
* @description
13
+
* 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.
14
+
*
15
+
* This hook is available in:
16
+
* - {@link p5.baseMaterialShader}
17
+
* - {@link p5.baseNormalShader}
18
+
* - {@link p5.baseColorShader}
19
+
* - {@link p5.baseStrokeShader}
20
+
*
21
+
* @param {function(Vertex): Vertex} callback
22
+
* A callback function which receives and returns a Vertex struct.
23
+
*
24
+
* @see {@link p5.baseMaterialShader}
25
+
* @see {@link p5.Shader#modify}
26
+
*
27
+
* @example
28
+
* <div modernizr='webgl'>
29
+
* <code>
30
+
* let myShader;
31
+
* function setup() {
32
+
* createCanvas(200, 200, WEBGL);
33
+
* myShader = baseMaterialShader().modify(() => {
34
+
* getWorldInputs(inputs => {
35
+
* // Move the vertex up and down in a wave
36
+
* inputs.position.y += 20 * sin(
37
+
* millis() * 0.001 + inputs.position.x * 0.05
38
+
* );
39
+
* return inputs;
40
+
* });
41
+
* });
42
+
* }
43
+
* function draw() {
44
+
* background(255);
45
+
* shader(myShader);
46
+
* lights();
47
+
* noStroke();
48
+
* fill('red');
49
+
* sphere(50);
50
+
* }
51
+
* </code>
52
+
* </div>
53
+
*/
54
+
55
+
/**
56
+
* @function combineColors
57
+
* @experimental
58
+
* @description
59
+
* 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 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).
0 commit comments