Skip to content

Commit 58d8e5d

Browse files
committed
Fix getPixelInputs description and getFinalColor example
1 parent 6e1311d commit 58d8e5d

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/webgl/ShaderGenerator.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,9 +1821,23 @@ if (typeof p5 !== 'undefined') {
18211821
/**
18221822
* @method getPixelInputs
18231823
* @description
1824-
* Registers a callback to modify the properties of each fragment (pixel) before the final color is calculated in the fragment shader. This hook can be used inside <a href="#/p5/baseMaterialShader">baseMaterialShader()</a>.modify() and similar shader modify calls to change opacity or other per-pixel properties. The callback receives an object with the following properties:
1825-
* - `opacity`: a number between 0 and 1 for the pixel's transparency
1826-
* - (Other properties may be available depending on the shader.)
1824+
* Registers a callback to modify per-fragment inputs before the final color is computed in the fragment shader. The available properties differ by shader:
1825+
* - For baseMaterialShader():
1826+
* - `normal` (vec3): surface normal
1827+
* - `texCoord` (vec2): texture coordinates
1828+
* - `ambientLight` (vec3): ambient light color
1829+
* - `ambientMaterial` (vec3): ambient material color
1830+
* - `specularMaterial` (vec3): specular material color
1831+
* - `emissiveMaterial` (vec3): emissive material color
1832+
* - `color` (vec4): base color (unpremultiplied)
1833+
* - `shininess` (float)
1834+
* - `metalness` (float)
1835+
* - For baseStrokeShader():
1836+
* - `color` (vec4): base color
1837+
* - `tangent` (vec2): tangent direction
1838+
* - `center` (vec2): stroke center for the current fragment
1839+
* - `position` (vec2): fragment position in stroke space
1840+
* - `strokeWeight` (float)
18271841
*
18281842
* Return the modified object to update the fragment.
18291843
*
@@ -1922,7 +1936,6 @@ if (typeof p5 !== 'undefined') {
19221936
* createCanvas(200, 200, WEBGL);
19231937
* myShader = baseColorShader().modify(() => {
19241938
* getFinalColor(color => {
1925-
* // Make the output color fully opaque and add a green tint
19261939
* // Add a blue tint to the output color
19271940
* color.b += 0.2;
19281941
* return color;

0 commit comments

Comments
 (0)